[mod_python] Changing the status code with custom content

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Dec 22 19:42:38 EST 2003


I believe you should req.write() your error page, set req.status to the
the error code you want and return apache.OK. If you retrun anything other
then apache.OK, then Apache assumes you want it to send its own stock
error page.

(Hope this answers your question, I'm a bit woozy on nuquil right now....)

Grisha

On Mon, 22 Dec 2003, Michael C. Neel wrote:

> I'm having trouble using mod_python to change the status code and have
> custom content in the error message.  If I return something other than
> apache.OK in my handler, the status line is set correctly set but apache
> returns the default error page.  If I have sent custom content for the
> error message, the apache error message is added to the end of the
> document.  I can get around this by using an ErrorDocument directive in
> apache's conf, but I loose access to the traceback of the error and thus
> the ability to have a really custom error message.
>
> At first glance this didn't seem to matter.  As long as the content said
> error, the user knew of the problem, even if the status was 200 OK.
> However I've found out now with search bots this does matter - they
> don't know that they have a bad url for the site and are indexing error
> pages thinking they are legit.
>
> Any thoughts on what I may be over looking?
>
> Thanks,
> Mike
>
> _______________________________________________
> 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