[mod_python] Quesiton about util.redirect()

Graham Dumpleton grahamd at dscpl.com.au
Mon Jun 27 18:11:44 EDT 2005


On 28/06/2005, at 1:04 AM, dharana wrote:

> I'm using a custom handler and I'm also using redirect(). Recently 
> I've noticed that redirect() raises apache.SERVER_RETURN, apache.OK. 
> Am I as the custom handler developer supposed to do anything with the 
> exception?
>
> I've noticed the exceptions now because I've added a wrapper in my 
> custom handler that notifies me if it catches any exception and now 
> I'm getting an exception every time there is a redirect.

In general you would raise it again. You should be doing this with any
sort of error. The top level mod_python code will then catch them, and 
in
the case of either:

   raise apache.SERVER_RETURN, apache.HTTP_MOVED_PERMANENTLY

or:

   req.status = apache.HTTP_MOVED_PERMANENTLY
   raise apache.SERVER_RETURN, apache.OK

it should effectively change it to:

   req.status = apache.HTTP_MOVED_PERMANENTLY
   return apache.OK

in the top level return.

If some Python code error is raised, the top level mod_python code will
turn it into a 500 error which trace back sent to browser if debug is 
on.

I think I have described that right.

Graham



More information about the Mod_python mailing list