[Twisted-web] how to redirect to another url

Alberto Trujillo alberto.trujillo at ucd.ie
Mon Sep 5 04:15:09 MDT 2005


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):
        http_equiv = ''
        content = ''
        myform = ctx.arg('form')
        if (myform == 'login'):
            if (self.executeLogin(ctx)):
                http_equiv = 'refresh'
                 href = url.here.curdir()
                 href = href.add('content', 'home')
30            # content = '2;URL=' + href

                #Temporal solution
33            content = '2;URL=http://localhost:' + str(HTTP_PORT)

        return {'http_equiv':http_equiv, 'content':content}




More information about the Twisted-web mailing list