[mod_python] conditions for a 404

Nicolas Lehuen nicolas at lehuen.com
Thu May 25 14:03:46 EDT 2006


Hi David,

First of all, you may want to read your Apache error log to get more
information. In some cases, for security reasons, the user gets a
simple 404 error whereas there is a more precise error message in the
log.

If you cannot read the error log, you can try switching on the
PythonDebug configuration directive to get more detailled error
messages on the client side. Don't forget to remove it when launching
your site on a production server, though, because those error messages
usually contain stack trace, which gives a little bit more data to a
would-be hacker than you would like.

BTW, even if this should not lead to the problem you observe, you are
using the handler's style of coding instead of the publisher style.
Published functions or methods do not return apache.OK, they simply
return a string that needs to be returned to the client, or None if
req.write() is used to send content to the client. Also, you do not
need to use req.send_http_headers().

All this is assuming that you are using the latest mod_python release,
namely the 3.2.8 one. If you don't then I strongly suggest you
upgrade, because you've missed more than one year of bugfixes.

Tell us what is your precise configuration and what you can find in
your error log if you need more help.

Regards,
Nicolas

2006/5/25, David Bear <David.Bear at asu.edu>:
> I have a file called tddb.py which contains
>
> """
> from mod_python import session
>
> def index(req):
>   req.content_type = "text/plain"
>   req.send_http_header()
>   req.write("hello world")
>   keys = req.keys()
>   for k in keys:
>     req.write("object name is %s " % k)
>   req.write("done")
>   return apache.OK
>
> It lives in a directory where publisher is set as the handler for all
> .py files.
>
> When I run this via url http://myserver/tddb.py apache returns a 404
> error.
>
> I've checked that the file perms on 755 and group own by the webserver
> group.
>
> I'm getting lost here. the more I use modpython the less I understand
> it. What could be wrong?
>
> --
> David Bear
> phone:  480-965-8257
> fax:    480-965-9189
> College of Public Programs/ASU
> Wilson Hall 232
> Tempe, AZ 85287-0803
>  "Beware the IP portfolio, everyone will be suspect of trespassing"
> _______________________________________________
> 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