[mod_python] Text Dump - Save me from insanity

Graham Dumpleton grahamd at dscpl.com.au
Wed Jun 1 18:39:19 EDT 2005


Alexis Marrero wrote ..
> I know that this is beaten horse but I don't know what else to do.
> 
> The problem is the good ol' "text dump" instead of script execution.
> 
> I read the fact and I have google it a thousand of times but I still 
> haven't make it work.
> 
> Here is my httpd.conf:
> .....
> DocumentRoot "/webapp/"
> 
> Alias / "/webapp/"
> <Directory "/webapp/">
>    SetHandler mod_python
>    PythonHandler index
>    PythonDebug On
> </Directory>
> ....
> 
> index.py is:
> 
> def index(req):
> 	req.write('hello')

This will not work at all even if you got it to execute.

> _---------
> 
> If I access, http://localhost/, I get a 404 Not Found, if I access 
> http://localhost/index.py I get a text dump of the script.
> 
> I also added the line, PythonPath "sys.path ['/webapp/']", and still 
> does the same thing.
> 
> Notice that I WANT SetHandler to be in my httpd.conf because I want to
> catch all requests to the root directory with index.py, nothing else.
> 
> What else should I try. I have been using mod_python for a while so I'm
> not that new to it.

For starters, read:

  http://www.dscpl.com.au/projects/vampire/articles/modpython-001.html

It provides a better example handler plus instructions and also tips for when
things don't work.

After getting that working and understanding the various gotchas and what
should be in a handler, then you might start playing with SetHandler.

BTW, for a SetHandler based dispatch mechanism, suggest you look at Vampire
extensions for mod_python. Even if you don't use it, you might learn something
from it. On the same site as the article:

  http://www.dscpl.com.au/projects/vampire

Graham


More information about the Mod_python mailing list