[mod_python] One index.py for all subdirectories

Manfred Stienstra manfred.stienstra at dwerg.net
Mon Dec 20 13:20:59 EST 2004


On Mon, 2004-12-20 at 18:29 +0100, Manfred Stienstra wrote:
> On Mon, 2004-12-20 at 11:42 -0500, Alexis Marrero-Narváez wrote:
> > All,
> > 
> > How can I setup Apache2, in such way that I only need one index.py for 
> > all subdirectories. For instance here is a directory structure:
> > /persons
> > 	/john
> > 		/daughters
> > 			/anna
> > 			/alicia
> > 	/mary
> > 	index.py
> > 
> > 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.

Manfred



More information about the Mod_python mailing list