[mod_python] Publisher and DEFLATE Filter

Graham Dumpleton grahamd at dscpl.com.au
Sat Dec 2 18:24:47 EST 2006

On 03/12/2006, at 9:56 AM, Jorey Bump wrote:

> Clodoaldo wrote:
>> 2006/12/2, Jorey Bump <list at joreybump.com>:
>>> Clodoaldo wrote:
>>> > As the Publisher does not require a py extension this obviously  
>>> does
>>> > not work. The AddOutputFilterByType directive is said to be  
>>> deprecated
>>> > in the 2.2.3 manual.
>>> Do you have a link to that statement? I don't see it mentioned here:
>>>   http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
>> It is here:
>> http://httpd.apache.org/docs/2.2/mod/core.html#addoutputfilterbytype
>> "Because of certain problems discussed below, this directive is  
>> deprecated."
> Crap. Well, as long as the offical documentation for mod_deflate  
> describes only the old method, it should be safe to use until the  
> docs are updated with a new alternative. It's obviously best to  
> operate on MIME types instead of file extensions, but try not to  
> get greedy. Some browsers even have trouble dealing with compressed  
> text/css. You'll get a lot of mileage out of compressing text/html,  
> text/plain, and text/xml alone.

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':
     return apache.OK

Using a fixup handler is possibly going to give you more control  
anyway as you
may want to do other checks to determine when to set filters and the  
may not give you that control. For example you might want to look at  
content type and extension.

   from mod_python import apache
   import os.path

   def fixuphandler(req):

     if req.content_type == 'text/html':
       extension = os.path.splitext(req.filename)[1]
       if extension = '.shtml':

     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. :-)


More information about the Mod_python mailing list