Reputation: 837
I'm using the Tornado framework
and have a Websockethandler
, which receives data from the client and the value is stored in a variable. How can I send that variable to another module. This is the code (partial):
#module a.py
class Handler(tornado.websocket.WebSocketHandler):
@tornado.web.asynchronous
@gen.engine
def on_message(self, event):
data = urlparse.parse_qs(event)
event= data.get('type')
How can the variable event
be passed to module b.py
Thanks
Upvotes: 1
Views: 337
Reputation: 59674
Make a function in module b.py
, for example on_message
and pass it your event
variable:
b.py
:
def handle_event(new_event):
print new_event
a.py
:
import b
class Handler(tornado.websocket.WebSocketHandler):
@tornado.web.asynchronous
@gen.engine
def on_message(self, event):
data = urlparse.parse_qs(event)
event= data.get('type')
b.handle_message(event) # this
Upvotes: 3