[mod_python] mod_python only returns 404 error's

Jim Gallacher jpg at jgassociates.ca
Sun Nov 5 15:26:06 EST 2006


Cryptronic wrote:
> Hi all,
> 
> i tried to use mod_python, installation from .deb works fine.
> 
> I'm running following configuration:
> Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4c0
> 
> then i tried to following skript:
> 
>  from mod_python import apache
> 
>  def handler(req):
>      req.content_type = "text/plain"
>      req.write("Hello World! Blarg!")
>      return apache.OK
> 
> 
> with rights: 755 owned by the suexec user
> 
> with the following vhost config:
> 
>       AddHandler python-program .py
>       PythonHandler mod_python.publisher
>       PythonDebug On
> 
> when i open the url in browser errlog shows me:
> [notice] mod_python: (Re)importing module 'mod_python.publisher'
> [notice] [client] Publisher loading page /var/www/test/test2.py
> 
> But i got in the browser only a 404 page -  no error's  in log - nothing :(

Your test2.py file is something you might use if you were writing your 
own handler. Publisher is a little different. It first looks for the 
index method. Try this (Notice :

def index(req):
     req.content_type = "text/plain"
     return "Hello World! Blarg!"


You can also do something like this:

def index(req):
     req.content_type = "text/plain"
     req.write("Hello World! Blarg!")

Notice that we are *not* returning apache.OK. Publisher looks after this 
for you.

You can also publish other methods in your file:

def foo(req):
     return "This is foo"

and fetch it with http://localhost/test/test2.py/foo

Jim



More information about the Mod_python mailing list