Jim Dabell
jim-mod-python at jimdabell.com
Thu Aug 26 12:33:14 EDT 2004
> (roughly), but what was happening was that my page was being sent, then > the normal Apache 404 handler was occuring. mod_python.c has this to say on the matter: /* When the script sets an error status by using req.status, * it can then either provide its own HTML error message or have * Apache provide one. To have Apache provide one, you need to send * no output and return the error from the handler function. However, * if the script is providing HTML, then the return value of the * handler should be OK, else the user will get both the script * output and the Apache output. */ So basically, you need to set req.status = apache.HTTP_NOT_FOUND (which is basically a synonym for 404, but perhaps clearer to read), and then return a value saying that no error occured, in order to successfully handle an error. That's backwards if you ask me, and definitely something that should be make clear in the manual. > The first header sent was including a 200 status as well. That's a separate problem; the status is sent as the very first line of the response, so you need to set req.status before sending any headers, else mod_python defaults to 200. -- Jim Dabell
|