[mod_python] Returning HTTP_MULTI_STATUS from a custom handler

Indrek Järve indrek at inversion.ee
Mon Jun 14 21:38:22 EDT 2004


Grisha,

Thanks, that did it!
Maybe this behaviour should be explained in a bit more detail in the
documentation for the future users? While now knowing this I can
semi-understand it from "Overview of a Request Handler" and "Request
Object/Request Members", it still seems a bit vague ;)

Regards,
Indrek

On Mon, 2004-06-14 at 20:24, Gregory (Grisha) Trubetskoy wrote:
> Indrek
> 
> If you want Apache to handle the error, you return it the error code. This
> will result in the behaviour you are seeing (an error page and a status of
> 200).
> 
> If you do not want Apache to handle the error (and in your case you do
> not), then set req.status yourself, write the necessary output (e.g. some
> html describing the error)  if any, and return apache.OK.
> 
> So the code you're looking for is:
> 
> def handler(req):
>     req.status = apache.HTTP_MULTI_STATUS
>     req.content_type = 'text/plain; charset=UTF-8"
>     req.write('hi!')
>     return apache.OK
> 
> This may seem confusing at first, but if you think about it it actually
> makes pretty good sense. :-)
> 
> Grisha



More information about the Mod_python mailing list