[mod_python] transhandler setup?

Graham Dumpleton grahamd at dscpl.com.au
Tue Aug 30 18:49:03 EDT 2005

On 31/08/2005, at 5:44 AM, IR labs wrote:

> Sorry for a late reply.
> I feel really silly for my problem, *really* silly. (almost too silly 
> to let you all know ...)
> After trying all different things in the httpd.conf and not seeing any 
> noticeable result, I started thinking it could be having to do with 
> apache not reading it after I issued "sudo apachectl restart". And 
> then I realized that, after I upgraded to apache 2, to make mod_python 
> work decently, I forgot to also change the path to 
> /usr/local/apache2/bin in my .profile. DUH... So every time I tried to 
> made a change to apache2's httpd.conf and "restarted" I restarted 
> apache 1, ... well, zero points for dirk and no desert for a week. :-(
> So I got everything working in the end.
> But thanks for this solution to have everything (also the stuff we 
> don't want to handle) handled by the handler in main.py.
> My only remaining question now, would be what you recommend?
> 1. Don't use the transhandle phase, and have *all* requests handled by 
> the main PythonHandler, including the ones it shouldn't handle ( 
> apache.DECLINE)
> or.
> 2. Use the TransHandler phase to discern between real physical present 
> files (requests for .html, .css, .js etc. files) and virtual pages 
> that should be handled by main.py

It all depends on exactly what you want to do, as these probably aren't
the only alternatives. If you want a request against a directory to be
rerouted, look at the DirectoryIndex directive. If you want to reroute a
request against a non existent file based on a specific extension type,
you may also be able to use mod_rewrite. Finally, there is also the
ErrorDocument directive for non existent files as well. All of these
might feasibly be harnessed to provide part of the solution and using
Python to make the decision may be a more complicated choice than some
of Apache's core features designed for this sort of thing.


More information about the Mod_python mailing list