[mod_python] Simulating non parsed header scripts

Gregory (Grisha) Trubetskoy grisha at modpython.org
Wed Apr 17 09:18:11 EST 2002


On Wed, 17 Apr 2002, Markus Demleitner wrote:

> Hi,
>
> The FAQ states that a redirection should be done this way:
>
>  req.headers_out['location'] = 'http://www.modpython.org/'
>      req.status = apache.HTTP_MOVED_TEMPORARILY
>      req.send_http_header()
>      return apache.OK
>
> Unfortunately, I couldn't find status in the docs, and so
> I'm a bit uncertain what else I can do with status.
> Basically, I want to port an nph-script, so is it ok
> to set status to whatever I want in the server's response
> line (500, 302, 200, whatever) and then return apache.OK?

Yes, if I remember it correctly, setting status to whatever, then
returning OK will work. You will probably need req.send_http_header() as
well, because I think that that is what actually sends the status line
out.


> Also, my classes generate "`raw"' http result codes (instead
> of symbolic names from the apache module).  I like it this
> way, because I can use them with or without mod_python.  Is
> there any danger in assigning those to req.status?

The constants are just integers. I like using them because they are more
descriptive than 302.

> Minor gripes: The link to the complete mailing list archive
> is dead, and in the docs for 5.1.9 PythonHandler, a % in the
> TeX source is missing a backslash.

Can you e-mail me off-list where specifically it is?

Grisha




More information about the Mod_python mailing list