class documentation

Represent a collection of templates that locates template source files from the local filesystem. The primary argument is the ``directories`` argument, the list of directories to search: .. sourcecode:: python lookup = TemplateLookup(["/path/to/templates"]) some_template = lookup.get_template("/index.html") The :class:`.TemplateLookup` can also be given :class:`.Template` objects programatically using :meth:`.put_string` or :meth:`.put_template`: .. sourcecode:: python lookup = TemplateLookup() lookup.put_string("base.html", ''' <html><body>${self.next()}</body></html> ''') lookup.put_string("hello.html", ''' <%include file='base.html'/> Hello, world ! ''') :param directories: A list of directory names which will be searched for a particular template URI. The URI is appended to each directory and the filesystem checked. :param collection_size: Approximate size of the collection used to store templates. If left at its default of ``-1``, the size is unbounded, and a plain Python dictionary is used to relate URI strings to :class:`.Template` instances. Otherwise, a least-recently-used cache object is used which will maintain the size of the collection approximately to the number given. :param filesystem_checks: When at its default value of ``True``, each call to :meth:`.TemplateLookup.get_template()` will compare the filesystem last modified time to the time in which an existing :class:`.Template` object was created. This allows the :class:`.TemplateLookup` to regenerate a new :class:`.Template` whenever the original source has been updated. Set this to ``False`` for a very minor performance increase. :param modulename_callable: A callable which, when present, is passed the path of the source file as well as the requested URI, and then returns the full path of the generated Python module file. This is used to inject alternate schemes for Python module location. If left at its default of ``None``, the built in system of generation based on ``module_directory`` plus ``uri`` is used. All other keyword parameters available for :class:`.Template` are mirrored here. When new :class:`.Template` objects are created, the keywords established with this :class:`.TemplateLookup` are passed on to each new :class:`.Template`.

Method __init__ Undocumented
Method adjust_uri Adjust the given ``uri`` based on the given relative URI.
Method filename_to_uri Convert the given ``filename`` to a URI relative to this :class:`.TemplateCollection`.
Method get_template Return a :class:`.Template` object corresponding to the given ``uri``.
Method put_string Place a new :class:`.Template` object into this :class:`.TemplateLookup`, based on the given string of ``text``.
Method put_template Place a new :class:`.Template` object into this :class:`.TemplateLookup`, based on the given :class:`.Template` object.
Instance Variable collection_size Undocumented
Instance Variable directories Undocumented
Instance Variable filesystem_checks Undocumented
Instance Variable module_directory Undocumented
Instance Variable modulename_callable Undocumented
Instance Variable template_args Undocumented
Method _check Undocumented
Method _load Undocumented
Method _relativeize Return the portion of a filename that is 'relative' to the directories in this lookup.
Instance Variable _collection Undocumented
Instance Variable _mutex Undocumented
Instance Variable _uri_cache Undocumented

Inherited from TemplateCollection:

Method has_template Return ``True`` if this :class:`.TemplateLookup` is capable of returning a :class:`.Template` object for the given ``uri``.
def __init__(self, directories=None, module_directory=None, filesystem_checks=True, collection_size=-1, format_exceptions=False, error_handler=None, output_encoding=None, encoding_errors='strict', cache_args=None, cache_impl='beaker', cache_enabled=True, cache_type=None, cache_dir=None, cache_url=None, modulename_callable=None, module_writer=None, default_filters=None, buffer_filters=(), strict_undefined=False, imports=None, future_imports=None, enable_loop=True, input_encoding=None, preprocessor=None, lexer_cls=None, include_error_handler=None): (source)

Undocumented

def adjust_uri(self, uri, relativeto): (source)

Adjust the given ``uri`` based on the given relative URI.

def filename_to_uri(self, filename): (source)

Convert the given ``filename`` to a URI relative to this :class:`.TemplateCollection`.

def get_template(self, uri): (source)

Return a :class:`.Template` object corresponding to the given ``uri``. .. note:: The ``relativeto`` argument is not supported here at the moment.

def put_string(self, uri, text): (source)

Place a new :class:`.Template` object into this :class:`.TemplateLookup`, based on the given string of ``text``.

def put_template(self, uri, template): (source)

Place a new :class:`.Template` object into this :class:`.TemplateLookup`, based on the given :class:`.Template` object.

collection_size = (source)

Undocumented

directories = (source)

Undocumented

filesystem_checks = (source)

Undocumented

module_directory = (source)

Undocumented

modulename_callable = (source)

Undocumented

template_args = (source)

Undocumented

def _check(self, uri, template): (source)

Undocumented

def _load(self, filename, uri): (source)

Undocumented

def _relativeize(self, filename): (source)

Return the portion of a filename that is 'relative' to the directories in this lookup.

_collection: dict = (source)

Undocumented

Undocumented

_uri_cache: dict = (source)

Undocumented