jinja2_adapters

Classes

Jinja2LoaderAdapter(env) Adapts the Jinja2 environment to act as a loader as desired by tornado.
Jinja2TemplateAdapter(template) Adapts the Jinja template interface to act as a tornado template.


class remoteappmanager.jinja2_adapters.Jinja2LoaderAdapter(env)[source]

Bases: object

Adapts the Jinja2 environment to act as a loader as desired by tornado.

The class uses duck typing to implement the interface of tornado.BaseLoader and relies on jinja caching to hold the premade templates.

Initializes the adapter.

Parameters:env (Environment) – the jinja2 environment
load(name, parent_path=None)[source]

Loads the template with a given name.

Parameters:
  • name (str) – the simple name of the template.
  • parent_path (str) – The parent path (unused)
Returns:

  • Jinja2TemplateAdapter object, adapting a jinja template into a tornado
  • template interface

reset()[source]

Resets the LRU cache in jinja template environment. The method is already thread safe.

resolve_path(name, parent_path=None)[source]

Returns the absolute name of the template according to the loader.

Parameters:
  • name (str) – the simple name of the template.
  • parent_path (str) – The parent path (unused)
Returns:

Return type:

The absolute path of the template

class remoteappmanager.jinja2_adapters.Jinja2TemplateAdapter(template)[source]

Bases: tornado.template.Template

Adapts the Jinja template interface to act as a tornado template. It reimplements the base class, but it uses no functionality of it.

generate(**kwargs)[source]

Generate this template with the given arguments.