[mod_python] One index.py for all subdirectories

Scott Sanders sanders at apache.org
Mon Dec 20 13:47:08 EST 2004

>>> I want the index.py in /persons to be used everytime the user access
>>> any URI under /persons. So if the user GET
>>> http://host.com/persons/john/daugthers/ apache handles the request by
>>> sending it to index.py inside /persons instead of trying to get
>>> /persons/john/daughters/index.py?
>>> Are there any tricks other than using mod_rewrite?
> Oops I misunderstood. You can set a handler for a directory:
> <Directory "/var/www/app/persons">
>         SetHandler python-program
>         PythonHandler handler::handler
> 	PythonPath "sys.path+['/var/www/app/lib']"
> </Directory>
> This assumes there is a handler.py somewhere in the sys.path with a
> function handler defined. All the requests for this directory will be
> handled by the PythonHandler.

I am using the SetHandler directive to do this now in my application.


More information about the Mod_python mailing list