Reputation: 561
How can I get access to the database connection in the UI Module? I'm using built-in wrapper for MySQL in Tornado.
My application is completely similar this
Upvotes: 2
Views: 553
Reputation: 51
Just map the module class, don't use a separated uimodule.py. Like this:
class EntryModule(tornado.web.UIModule):
def render(self, entry):
return self.render_string('modules-entry.html', entry=entry)
settings = {
"login_url": "/login",
ui_modules={"Entry": EntryModule},
}
application = tornado.web.Application([
(r"/", HomeHandler),
(r"/entry/([0-9]+)", EntryHandler),
], **settings)
Notice : ui_modules={"Entry": EntryModule}
Upvotes: 2