[mod_python] newb question on apache conf

Jorey Bump list at joreybump.com
Fri Feb 25 22:25:00 EST 2005


Graham Dumpleton wrote:

> Alternatively, try using:
> 
> <Directory "path/to/my/directory">
>      SetHandler mod_python
>      PythonHandler mod_python.publisher
>      PythonDebug On
>      <Files *.html>
>           SetHandler None
>      </Files>
> </Directory>
> 
> In other words, default is to send everything through mod_python.publisher
> but you list exceptions which you don't want to be using <Files> and
> resetting the handler back to None. You may though want to do this for
> all sorts of files, eg, *.jpg, *.png, *.gif etc etc, which may be more
> trouble that its worth.

And possibly in the category of stupid apache/mod_python tricks:

<Directory /var/www>
     <FilesMatch "foo">
         SetHandler python-program
         PythonHandler mod_python.publisher
         PythonDebug On
     </FilesMatch>
</Directory>

This would allow you to mix and match file types to your heart's 
content, as long as the names of all (and only) published modules 
include "foo":

  http://host/foobar.py/somefunction

As a bonus, extension hiding still works:

  http://host/shipoffools/somefunction

As do modules in subdirectories:

  http://host/subdir/spamisnotfood/somefunction

But you can't do this:

  http://host/tomfoolery.jpg

This could be a lot of fun in a team environment, when other modules 
return a "Not found" error, while your cleverly named modules work fine. 
  Hmmm, April is on its way, I'd better find myself a team... :)


More information about the Mod_python mailing list