[mod_python] Problem with mapping URIs to filesystem/Python modules

Fabian Fagerholm fabbe at paniq.net
Wed May 12 13:20:04 EDT 2004


It's been a while since I last used mod_python, but now I'm having a
look at it again. I'm trying to figure out how to accomplish a clean
mapping between URIs and the filesystem and Python modules/functions.

What I want is to be able to create a kind of "virtual directory" that
is actually handled by mod_python. It should coexist with other "virtual
directories" and regular directories in the file system. The problem is
I can't get past the .py extension either using the publisher handler,
or writing my own handler.

Here's an example. The directory structure looks like this (located in
my public_html directory):


These are all real directories in the file system. Now, I know how to
map requests for / to, say, index.py by using AddHandler and
DirectoryIndex in a .htaccess file. Also, I could add a handler for /aaa
by making /aaa/aaa.py and using a corresponding .htaccess file in /aaa.
This is all fine.

The problem is this: when accessing /, the request maps to /index.py
because of the DirectoryIndex directive. But if I wanted to create a
"virtual directory" /virt, which would map to /index.py/virt (calling
the virt function in the index.py module) then the only way is to
actually call it by name.

How can I hide index.py in the URI?

Fabian Fagerholm <fabbe at paniq.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mailman.modpython.org/pipermail/mod_python/attachments/20040512/6ab96c56/attachment.bin

More information about the Mod_python mailing list