Initialization parameters to SocketServer handler?
Grant Edwards
grante at visi.com
Fri Apr 13 00:14:23 EDT 2001
What's the right way to pass initialization parameters to a
SocketServer handler instance? I'm currently setting attributes
in the server instance and reading them in the handler method
via self.server.<attribute>. It works but it seems a bit
obtuse:
class PortForwarder(SocketServer.BaseRequestHandler):
def handle(self):
sys.stdout.write("connection from %s\n" % str(self.client_address))
self.forward = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.forward.connect(self.server.forwardAddr)
[...]
serv = SocketServer.TCPServer(("",4567),PortForwarder)
serv.forwardAddr = ("localhost",25)
serv.serve_forever()
--
Grant Edwards grante Yow! Now I am depressed...
at
visi.com
More information about the Python-list
mailing list