Back to index

plone3  3.1.7
enableHTTPCompression.py
Go to the documentation of this file.
00001 ## Script (Python) "enableHTTPCompression"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=request=None, force=0, debug=0, css=0, js=0
00008 ##title=Enable zlib based HTTP compression
00009 
00010 # force: force http compression even if the browser doesn't send an accept
00011 # debug: return compression state (0: no, 1: yes, 2: force)
00012 # css: set this to 1 inside a css file (for later use)
00013 # js: set this to 1 inside a js file (for later use)
00014 
00015 # Set this to 1 to enable Zope's HTTP compression
00016 ENABLE_ZLIB_COMPRESSION = 0
00017 
00018 if not ENABLE_ZLIB_COMPRESSION:
00019     if debug:
00020         return '<!-- compression status: disabled -->'
00021     else:
00022         return
00023 
00024 if request is None:
00025     request = context.REQUEST
00026     
00027 result = request.RESPONSE.enableHTTPCompression(REQUEST=request, force=force)
00028 
00029 if debug:
00030     return '<!-- compression status: %s -->' % result