[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 20:17:13 EST 2003

Simon Willison wrote:
> 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.

Well, I've worked out the second option. My .htaccess file now looks 
like this:

SetHandler python-program
PythonHandler handler
PythonDebug On

This sends ALL requests to stuff within that directory to handler.py's 
handler() function. I've drawn a blank on getting it not to do this with 
images. I tried the following:

AddHandler default-handler .html .jpeg .jpg .gif .css .js
SetHandler python-program
PythonHandler handler
PythonDebug On

But this didn't work - presumably because the SetHandler over-rides the 
AddHandler directive. I tried changing their order but didn't have any 
luck there either.

Any help on this would be greatly appreciated :)



More information about the Mod_python mailing list