J
Jean-Pierre Bergamin
Hello
I have the following class structure:
class MyServer:
x= 0
class MyHandler(SocketServer.StreamRequestHandler):
def handle(self):
if x: # <---- How to get the X from the parent class?
# Or how to pass a value to this class anyway?
do_something()
else:
do_something_else()
def start_server(self):
s = SocketServer.TCPServer(('', 1234), self.MyHandler)
s.server_forevert()
server = MyServer
server.x = 10
server.start_server()
How is it possible to get the value of x from the class MyServer within the
MyHandler class?
The object of self.MyHandler is instantiated everytine the
SocketServer.TCPServer calls handle, so it's not possible to create an
instance of MyHandler an pass it the value.
Or ist there any other possibility to pass the class MyHandler some values?
Thanks in advance.
James
I have the following class structure:
class MyServer:
x= 0
class MyHandler(SocketServer.StreamRequestHandler):
def handle(self):
if x: # <---- How to get the X from the parent class?
# Or how to pass a value to this class anyway?
do_something()
else:
do_something_else()
def start_server(self):
s = SocketServer.TCPServer(('', 1234), self.MyHandler)
s.server_forevert()
server = MyServer
server.x = 10
server.start_server()
How is it possible to get the value of x from the class MyServer within the
MyHandler class?
The object of self.MyHandler is instantiated everytine the
SocketServer.TCPServer calls handle, so it's not possible to create an
instance of MyHandler an pass it the value.
Or ist there any other possibility to pass the class MyHandler some values?
Thanks in advance.
James