[mod_python] transhandler setup?

Graham Dumpleton grahamd at dscpl.com.au
Thu Aug 25 17:01:52 EDT 2005


If you want all requests falling under a directory to be handled by
mod_python use SetHandler and not AddHandler. Eg.

   <Directory /some/path>
   SetHandler mod_python
   PythonHandler main
   </Directory>

Read the documentation for further information of the difference.

On 25/08/2005, at 9:21 PM, IR labs wrote:

> Hi All, a mod_python newbie here.
>
> I am trying to set up my server using mod_python's transhandler, but I 
> can't figure out the right configuration. I am experimenting with the 
> most crude and basic uri translation possible: every request should be 
> redirected to main.py. But somehow apache doesn't want to do that. 
> Right now it still displays static pages (.html files) with images, 
> etc etc. (where I would think req.filename = 
> '/var/www/mod_python_test/main.py' should prevent all of that.)
>
> This is my setup:
>
> from httpd.conf :
> -----------------------------------------
> ...
> <IfModule mod_python.c>
>     AddHandler mod_python .py
>     PythonPath "sys.path + ['/var/www/mod_python_test/']"
>     PythonTransHandler translate
>
> </IfModule>
> ...
> -----------------------------------------
>
> my script
> /var/www/mod_python_test/translate.py :
> -----------------------------------------
> from mod_python import apache
>
> def transhandler(req):
> 	req.filename = '/var/www/mod_python_test/main.py'
> 	return apache.OK
> -----------------------------------------
>
> using
> FreeBSD 5.2.1
> Apache 2.0.54
> mod_python 3.1.4
> Python 2.3.2
>
>
> Note that my main.py does work through the .htaccess in 
> /var/www/mod_python_test/
> -----------------------------------------
> AddHandler mod_python .py
> PythonHandler main
> PythonDebug On
> -----------------------------------------
>
> But it (main.py) should be called for all the url's requested (not 
> just for /mod_python_test/whatever.py and friends.)
> thx
> dirk
>
>
>
>
> -----------------------------
> Dirk van Oosterbosch
> de Wittenstraat 225
> 1052 AT Amsterdam
> the Netherlands
>
> http://labs.ixopusada.com
> -----------------------------
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list