class MainHandler(BaseHandler):
@tornado.web.authenticated
def get(self):
self.render("index.html", messages=MessageMixin.cache)
因此,
MainHandler
不会将request
或current_user
传递给index.html
。但是在index.html
中,我尝试了<p>{{ current_user }}</p> <p>{{ request }}</p>
,然后生成了很多输出。那么龙卷风中的这种“全局变量”呢? 最佳答案
龙卷风模板免费提供了几样东西。
这些变量不需要传入-这就是您在current_user和request中看到的内容。
这是默认情况下获得的所有变量的list
关于python - Tornado - Tornado 中的“全局变量”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16234033/