[Twisted-web] HTTP redirection from data_*/render_* methods

en.karpachov at ospaz.ru en.karpachov at ospaz.ru
Fri Jul 15 08:17:48 MDT 2005

On Fri, Jul 15, 2005 at 07:40:33AM -0600, Samuel Reynolds wrote:
> At 2005-07-15 02:46 PM +0400, you wrote:
> >I wondered if I can make an HTTP redirection (302) from inside of render_*
> >or data_* method. Here is a code snipped I wrote; I'd like to know if it
> >can be considered as "good" nevow practice?
> What about
>     request.redirect( redirectUrl )
> possibly followed by
>     request.finish()

It doesn't work when called from inside a render_something or data_smth
methods. If I redirect, I want the flattening process to stop immediately,
dropping request output accumulated so far. The only way to do it is to
raise an exception, cancelling normal flow.  Otherwise, flattening will
continue, and the request will be finished twice. Also, the http reply will
have non-empty body.


More information about the Twisted-web mailing list