Tornado Documentation
http://www.v2ex.com/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
beta4better
V2EX  ›  Tornado

请教下:tornado.web.RequestHandler里的那个application的实例是在什么时候传递的?

  •  
  •   beta4better · Aug 11, 2012 · 6611 views
    This topic created in 5022 days ago, the information mentioned may be changed or developed.
    最近在学习Tornado, 看自带blog实例发现, BaseHandler并没有显示的调用父类的__init__方法,但是却使用了self.application.db 这个变量。然后去看源代码发现RequestHandler里有个application参数,但是一直没看到在哪里调用。

    请前辈们指教。
    2 replies    1970-01-01 08:00:00 +08:00
    ipconfiger
        1
    ipconfiger  
       Aug 13, 2012
    看图

    基类构造器在构造子类实例的时候已经被调用过了
    ipconfiger
        2
    ipconfiger  
       Aug 13, 2012   ❤️ 1
    另注意看源码里web.py 第1388行


    第一个参数self就是application对象本身。就是这个位置传进去的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4263 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 00:57 · PVG 08:57 · LAX 17:57 · JFK 20:57
    ♥ Do have faith in what you're doing.