[mod_python] Mapping a URI to pages dynamically.

Mike Looijmans mike.looijmans at asml.com
Mon May 19 14:51:05 EST 2003


I chose option #4: Build your own.

I just have /xx scriptaliased to point to a single .py handler. That one takes
the uri (request.path_info) and uses that to make the proper call.

I made it so that the request is like:

/xx/session/script...


(session could be a session ID, or name of database to use, and such).

The figures out which module to (re)import (the one named "script" in this
case), loads it, firgures out the parameters (usually the request object,
authorization information and a database connection) and calls its "main"
function.

Took about an hour to invent, implement and test and has been working
flawlessly for months. I like this language :-)
And it's backwards compatible with CGI too, at least, to the extent that I
need, so that servers without mod_python can use the same codebase (only the
initial handler differs).

Mike.




More information about the Mod_python mailing list