[mod_python] capturing and handling python errors in mod_python

Graham Dumpleton grahamd at dscpl.com.au
Mon Nov 14 16:52:23 EST 2005


Waitman Gobble wrote ..
> <?> one thing I've noticed is that ALL requests go to PythonLogHandler
> regardless of my "Files SetHandler None" directive."
> 
> If I put
>     file = open("/home/wwweb/pyblog/log/output.txt", "at")
>     file.write(str(req.the_request)+"\t"+str(req.status)+"\n");
>     file.close()
> 
> in my index.py then I get this in output.txt
> 
> GET / HTTP/1.1  200
> GET / HTTP/1.1  200
> GET / HTTP/1.1  200
> 
> 
> 
> if I put the same thing in log.py then I get this stuff:
> 
> GET / HTTP/1.1  200
> GET /css/548xAF.css HTTP/1.1    304
> GET /images/pyblog.png HTTP/1.1 304
> 
> Why are the requests for PNG, CSS etc going to log.py???
> 
> 
>         <Directory "/home/wwweb/pyblog/htdocs">
>             SetHandler mod_python
>             PythonHandler mod_python.publisher
>             PythonDebug Off
>             PythonLogHandler log::logger
>             Options none
>             AllowOverride none
>             Allow from all
>                 <Files ~ "\.(gif|jpe?g|png|html?|css|js)$">
>                         SetHandler None
>                 </Files>
>                 <Files *.pyc>
>                         Deny from all
>                 </Files>
>         </Directory>

The SetHandler/AddHandler directives only control for what situations
the handler specified by the PythonHandler directive is called. If
SetHandler/AddHandler are not used then PythonHandler will not be
called at all.

At the same time though, even if SetHandler/AddHandler isn't defined,
all other handlers which can be specified using the Python*Handler
directives are still called.

Thus, even if mod_python is not used to produce the actual content for
a response, any specified authentication, access, log handlers etc, will
still be called.

Graham


More information about the Mod_python mailing list