[Twisted-web] how to redirect to another url

Valentino Volonghi aka Dialtone dialtone at divmod.com
Mon Sep 5 05:16:47 MDT 2005

Alberto Trujillo wrote:

> Hello:
> Could anybody tell me what I must change in the next code to do an
> automatic redirection of url.
> I need something similar to the line 30, but this doesn't work. I have
> created a temporal solution in the line 33 and everything works ok,
> but of course if the url is different to 'localhost', nothing works.
> Thanks you very much.
> file.py
> -----------
>    def data_header(self, ctx, data):

Too late.
If you want to redirect you have to do that in:
locateChild or a child_something method returning an url object or
calling: inevow.IRequest(ctx).redirect('where/')

or in beforeRender method.

otherwise you have to make the page bufferized and then call
IRequest(ctx).redirect() to do what you need.

there are no other ways to redirect.

Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4.1
Blog: http://vvolonghi.blogspot.com

More information about the Twisted-web mailing list