class MainHandler(BaseHandler):
    @tornado.web.authenticated
    def get(self):
        self.render("index.html", messages=MessageMixin.cache)


因此,MainHandler不会将requestcurrent_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/

10-12 00:37
查看更多