[mod_python] Newbie question: setting all calls to a certain directory to beprocessed by a script

Simon Willison cs1spw at bath.ac.uk
Wed Aug 27 19:55:15 EST 2003


Hi all,

I'm new to mod_python, and I'm just beginning to get my feet wet. I'm 
currently setting directives in .htaccess files because I don't want to 
mess around too much with my httpd.conf file. I want to set it up so 
that ALL calls to a certain directory are handled by a handle() function 
in a specific file.

The mod_python documentation shows how to do this for any files ending 
in .py:

AddHandler python-program .py
PythonHandler myscript

I understand that the above passes all requests for URLs in the 
directory ending with .py to the handle() function I've defined in 
myscript.py in that directory. I'm a big fan of "tidy" URLs, and try to 
avoid having any file extension on URLs at all. Ideally, I would like to 
set up a rule so that any requests for files that do NOT end in .jpg, 
.js, .gif or .css are handed off to the handle() function in the file of 
my choice. If that isn't possible, I'd like to set it up so that all 
requests within the directory in which my .htaccess file lives are 
handled by the one handle() function.

Thanks,

Simon Willison




More information about the Mod_python mailing list