[mod_python] Mysterious 500 error? Solved!

Graham Dumpleton graham.dumpleton at gmail.com
Mon Jul 16 02:57:14 EDT 2007

On 16/07/07, Peter Shinners <pete at shinners.org> wrote:
> Peter Shinners wrote:
> > def handler(req):
> >     path = req.uri.split("/", 2)[-1]
> >     if path == "magic.html":
> >         req.content_type = "text/html"
> >         req.status = apache.OK
> >         req.send_http_header()
> >         req.write("<html><body>It is ok</body></html>")
> >         return apache.OK
> Found and fixed the problem. Just setting request.status seems to
> desginate an error. Even if setting to apache.OK. By not setting any
> status when things are ok, I get clean and clear 200 statuses.

Of course. :-)

req.status must be a HTTP status value. apache.OK is 0 which Apache
would see as being an invalid status code and it would most likely
return 500 error as a result to indicate a problem.

I did think setting req.status wasn't a good thing to do in this case,
but didn't occur to me that that would be the problem.


More information about the Mod_python mailing list