A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/081245.html below:

Initialization parameters to SocketServer handler?

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4