Found a very simple way to do what I need to do with no code changes
needed to request.py, here's the code:
# Psudeo Template Lookup that returns our Template Object
class TemplateLookupTornado(object):
def get_template(self, template_name):
return TemplateTornado(template_name)
# Psudeo Template that maps "render" to "generate"
class TemplateTornado(object):
def __init__(self, template_file):
loader = template.Loader(options.template_path)
self.template = loader.load(template_file)
def render(self, **kwargs):
return self.template.generate(**kwargs)
class BaseRequestTornado(BaseRequest):
def _get_template_lookup(self,extra_imports=None):
return TemplateLookupTornado()
So my BaseRequestTornado class over rides the internal
_get_template_lookup and returns an object TemplateLookupTornado class
that implements the get_template method, returning a TemplateTornado
object, So these classes map the mako calls for template, load and
render into Tornado ones. This meands the "render_template" call can
just execute as normal (and I get access to the xsrf stuff - which is
why I had to solve this problem).