Login

Compact P3P policy header injection middleware

Author:
mwolgemuth
Posted:
September 25, 2008
Language:
Python
Version:
1.0
Score:
0 (after 0 ratings)

This is like snippet 786, except it does it at the middleware layer, so you don't have to reference it in every view. Super simple.

refer to: http://www.djangosnippets.org/snippets/786/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
P3P_COMPACT = 'some string' # I import this from a global constants file
# eg. P3P_COMPACT='CP="CAO DSP CURa ADMa DEVa TAIa CONa OUR DELa BUS IND PHY ONL UNI PUR COM NAV DEM STA"'

class MiddlewareResponseInjectP3P(object):
    def __init__(self):
        self.process_response = self.inject

    def inject(self, request, response):
        response['P3P'] = P3P_COMPACT
        return response

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 2 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 2 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 9 months, 2 weeks ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 10 months, 1 week ago
  5. Help text hyperlinks by sa2812 11 months ago

Comments

EmilStenstrom (on November 24, 2011):

Excellent, thanks!

#

Please login first before commenting.