本文整理汇总了Python中dispatcher.Dispatcher.add方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatcher.add方法的具体用法?Python Dispatcher.add怎么用?Python Dispatcher.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dispatcher.Dispatcher
的用法示例。
在下文中一共展示了Dispatcher.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import add [as 别名]
def test(self):
c = Context('Root')
c.start()
o0 = self.SampleObj()
Dispatcher.add(obj=o0, parent_obj=None, context=c)
o1 = self.SampleObj()
Dispatcher.add(obj=o1, parent_obj=None, context=c)
Dispatcher.add_listener(src_obj=o1, dst_obj=o0)
Dispatcher.send(event=Event('1'), src_obj=o0, dst_obj=o1)
assert str(o1.lastHandler) == 'on1'
Dispatcher.queue(event=Event('2'), src_obj=o0, dst_obj=o1)
#assert str(o1.lastHandler) == 'on2'
Dispatcher.send(event=Event('3'), src_obj=o0, dst_obj=o1)
#assert str(o1.lastHandler) == 'on3'
Dispatcher.notify(event=Event('4'), src_obj=o1)
#assert str(o1.lastHandler) == 'on4'
Dispatcher.notify(event=Event('4'), src_obj=o1)
#assert str(o1.lastHandler) == 'on4'
c.stop()
示例2: test
# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import add [as 别名]
def test(self):
d = Dispatcher()
c = Context('Root')
c.start()
o = self.SampleObj()
d.add(obj=o, parent_obj=None, context=c)
o.Start()
assert str(o.state.current_state) == o.STATE_STARTED
assert str(o.last_handler) == 'inStarted_onEnter'
o.Pause()
assert str(o.state.current_state) == 'Paused'
assert str(o.last_handler) == 'inPaused_onEnter'
o.Stop()
assert str(o.state.current_state) == 'Stopped'
assert str(o.last_handler) == 'inStopped_onEnter'
c.stop()
示例3: Dispatcher
# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import add [as 别名]
from dispatcher import Dispatcher
dispatcher = Dispatcher()
dispatcher.add(r'^/$', 'views.uplaod_page')
dispatcher.add(r'^/upload_service$', 'views.upload_service')
dispatcher.add(r'^/uploadfile$', 'views.upload_handling')
HOST = '172.31.214.119'
PORT = 8089
if __name__ == "__main__":
from wsgiref.simple_server import make_server
server = make_server(HOST, PORT, dispatcher)
print 'Starting up HTTP server on %s: %i..........' %(HOST,PORT)
# server.serve_forever()
server.handle_request()