当前位置: 首页>>代码示例>>Python>>正文


Python Dispatcher.add方法代码示例

本文整理汇总了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()
开发者ID:CaveMike,项目名称:iron,代码行数:28,代码来源:test_dispatcher.py

示例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()
开发者ID:CaveMike,项目名称:iron,代码行数:22,代码来源:test_state.py

示例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()

开发者ID:kinglongchen,项目名称:sc-pro,代码行数:17,代码来源:url.py


注:本文中的dispatcher.Dispatcher.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。