[Twisted-Python] tcp.GetHost in twisted.web.server

Benjamin Bruheim grolgh at online.no
Sat Sep 8 13:34:44 MDT 2001


> >     def getHost(self):
> >         return self.transport.GetHost()
> Can't recall any reason for it at the moment except for the fact that your
> capitalization is wrong and those methods do subtly different things... :-)

Well, it wasn't just that. :) With the correct casing it went nuts (because I 
didn't bother to check if it was run at all; it is only used in connection with
cgi):

    def getHost(self):
        return socket.gethostbyaddr(self.transport.getHost()[1])

works better :) 

> > This at least doesn't make the crash go bad in win98
> What crash?

The bug was that it used the network socket which isn't your only choice all the time.
Now the routine works for localhost too. The reason it went bad under win98 was
because I wasn't always online (modem), and gethostbyaddr couldn't find eg.
the machinename 'phed' :P The big difference is that _host was generated only at 
the creation of the Request-class.

// phed







More information about the Twisted-Python mailing list