[mod_python] Redirect from publisher?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Tue Nov 6 13:22:35 EST 2001


On Tue, 6 Nov 2001, Alexander Steinert wrote:

> Some of my mod_python.publisher functions want to redirect the client to
> another URL under certain conditions (e.g. redirect from a secure server
> to an insecure or vice versa).
>
> Do you consider this a bad idea?

Redirect from a secure server to an insecure is probably a bad idea... ;-)

> My first approach would be to let the publisher function set an
> attribute of the request object and return nothing, so that a special
> handler (called after the publisher) can do the redirect (as described
> in the FAQ). What do you think?

Not sure I understand why you need a special handler for it, something
like this should work with the publisher:

     req.headers_out['location'] = 'http://www.modpython.org/'
     req.status = apache.HTTP_MOVED_TEMPORARILY
     return "You are being redirected to http://www.modpython.org/"



Grisha




More information about the Mod_python mailing list