[mod_python] Publisher and DEFLATE Filter

Graham Dumpleton grahamd at dscpl.com.au
Sat Dec 2 18:59:52 EST 2006


On 03/12/2006, at 10:46 AM, Jorey Bump wrote:

> Graham Dumpleton wrote:
>
>> Of if using mod_python 3.3 just use:
>>   PythonFixupHandler install_filters
>> In that handler module have:
>>   from mod_python import apache
>>   def fixuphandler(req):
>>     if req.content_type == 'text/html':
>>       req.add_output_filter('INCLUDES')
>>     return apache.OK
>
> Should that be:
>
>     req.add_output_filter('DEFLATE')

Since I was using a .shtml extension which is what is used for server  
side
includes, I switched gears and simply showed an alternate filter in  
action
to what you guys were originally talking about. :-)

Maybe I should show both in action:

   from mod_python import apache
   def fixuphandler(req):
     if req.content_type == 'text/html':
       req.add_output_filter('INCLUDES')
       req.add_output_filter('DEFLATE')
     return apache.OK

>> To me this is getting to what mod_python is really about, it is a  
>> means of programming
>> Apache by using all the various phases as they are intended and  
>> not just a jumping off
>> point for content handlers to WSGI, Django, TurboGears etc. :-)
>
> This *is* exciting, but when administering a server that supports  
> mod_python, PHP, CGI, ColdFusion, static HTML, etc., it's more  
> expedient to configure mod_deflate in the main httpd config, so  
> that it applies to all virtual hosts and matching content.

True.

Although the fixup handler is run within the context of mod_python,  
it is still setting
up the output filter for all requests with that content type or  
extension, regardless
of how the content handler phase is implemented so as to provide that  
content.

Thus, the above fixuphandler would still apply to where content was  
produced by
PHP, CGI, ColdFusion, static HTML etc.

I am sure you realise this, but thought I would clarify this in case  
others thought
that it would only apply where mod_python was used for the content  
handler phase.

Graham


More information about the Mod_python mailing list