[mod_python] Subdirectory handler...

Jim Gallacher jpg at jgassociates.ca
Fri Sep 22 08:38:10 EDT 2006

durumdara wrote:
> Hi !
> Can I define a python handler that global for htdocs and subdirectories 
> too ?
> How to do it ?

Same as you are doing now, but in the server context (or virtual host
context), not the directory context. The only trick is to make sure your 
script is on your python path so mod_python can find it. If it is 
outside your python path, use the PythonPath directive

# Setup the default handler
# Handler script is /tmp/stuff/foo.py

AddHandler mod_python .py
PythonHandler foo
PythonPath "['/tmp/stuff',] + sys.path"
PythonDebug On

<Directory c:/web/apache22/htdocs/>
  # htdocs and subdirectories will be handled by
  # the default /tmp/stuff/foo.py script

# you can override the default handler for a subdirectory

<Directory c:/web/apache22/htdocs/special/>
   AddHandler mod_python .py
   PythonHandler bar
   PythonDebug On


More information about the Mod_python mailing list