[mod_python] PostReadRequestHandler

Graham Dumpleton grahamd at dscpl.com.au
Fri Jul 15 20:28:57 EDT 2005

On 16/07/2005, at 5:50 AM, Jim Hefferon wrote:

> Instead, when I restart apache, it gives me a 404 every time, and every
> time sends me a copy of the cgi program that is the 404 error handler.
> That is, that the 404 should be executed as a cgi is gone (of course, 
> it
> works if I comment out the lines above from the 000-default and restart
> and ask for something that isn't there).  The error.log says "attempt 
> to
> serve directory" so it is not looking for the index.html file in the
> dir.  So I'm thinking that all subsequent handlers are not being
> invoked, or else that I am just clueless (I suspect that latter!).

When you use SetHandler to enable mod_python, it effectively disables 
execution of other high level handlers. This is a problem when you are
using PythonHandler to generate content for some requests and declining
others. For example, if you wanted ".php" files to be treated normally
they will not.

In your case, you aren't using PythonHandler and it isn't actually
necessary to use SetHandler or AddHandler to enable mod_python as that
is only required if you are specifying PythonHandler for content phase.
It isn't necessary when you are only defining handlers for other phases.
 From memory this isn't obvious from documentation and I only even
stumbled across it by accident. I just hope my memory is correct. :-)

Thus, comment out SetHandler and try:

   #SetHandler mod_python
   PythonPath "sys.path+['/dir/containing/py/file']"
   PythonPostReadRequestHandler filename
   PythonDebug On

If you were using PythonHandler for some content delivery, the only way
of ensuring other high level handlers run properly, is to disable the
SetHandler for those extension types. For example, you might have:

   SetHandler mod_python
   PythonHandler filename

   <Files *.php>
   SetHandler None

   <Files *.cgi>
   SetHandler None


More information about the Mod_python mailing list