V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Tornado Documentation
http://www.v2ex.com/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
paulguo
V2EX  ›  Tornado

如何在某个Handler中调用另一个Handler的方法?

  •  
  •   paulguo · 2012-12-08 19:32:06 +08:00 · 5274 次点击
    这是一个创建于 4128 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如

    class AHandler(BaseHandler):
    def get(self):
    // do sth

    class BHandler(BaseHandler):
    def get(self):
    // 调用 AHandler.get() ?
    2 条回复    1970-01-01 08:00:00 +08:00
    reorx
        1
    reorx  
       2012-12-08 21:00:26 +08:00   ❤️ 2
    不能直接调用另一个 handler 的 http 方法,如果两个 get 有相同的部分,把那一部分提取出来写成 mixin class 的方法,然后让两个 handler 都继承它。

    http://gist.github.com/4240166
    paulguo
        2
    paulguo  
    OP
       2012-12-08 21:44:43 +08:00
    @reorx thx. :)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1622 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 16:52 · PVG 00:52 · LAX 09:52 · JFK 12:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.