Search code examples
pythonwebtornado

Tornado - 'Global variables' in tornado?


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

So the MainHandler does not pass request or current_user to index.html. But in index.html I tried <p>{{ current_user }}</p> <p>{{ request }}</p> and then there's a lot of output generated. So is this some kind of 'global variable' in Tornado ?


Solution

  • Several things are given to you for free in Tornado templates.

    These variables do not need to be passed in - this is what you are seeing this with current_user and request.

    Here is a list of all the variables you get by default