Mitzi
Mitzi

Reputation: 2811

Tornado template loader from string - Heroku

I am deploying a tornado server on Heroku. I currently load templates from files the standard way. I would like to load them from a database field and not from a file.

How do I do that the clean way?

Thanks!

Upvotes: 0

Views: 519

Answers (1)

Nikolay Fominyh
Nikolay Fominyh

Reputation: 9256

Try to use Template instead of Loader.

It will be simple as:

from tornado.template import Template
t = Template(my_template_string_from_database)
r = t.generate(key=value) #as we do in loader

Example not checked, but think this way. And don't be afraid of tornado code - it's easy to read it.

Upvotes: 2

Related Questions