PackageLoader Class

Inheritance diagram of PackageLoader

class PackageLoader(package_name, package_path='templates', encoding='utf-8')

Load templates from python eggs or packages. It is constructed with the name of the python package and the path to the templates in that package:

loader = PackageLoader('mypackage', 'views')

If the package path is not given, 'templates' is assumed.

Per default the template encoding is 'utf-8' which can be changed by setting the encoding parameter to something else. Due to the nature of eggs it’s only possible to reload templates if the package was loaded from the file system and not a zip file.


__init__(package_name[, package_path, encoding])
get_source(environment, template)
load(environment, name[, globals]) Loads a template.


has_source_access bool(x) -> bool


class PackageLoader

Method details

__init__(package_name, package_path='templates', encoding='utf-8')
get_source(environment, template)

Inherited member details

load(environment, name, globals=None)

Loads a template. This method looks up the template in the cache or loads one by calling get_source(). Subclasses should not override this method as loaders working on collections of other loaders (such as PrefixLoader or ChoiceLoader) will not call this method but get_source directly.

has_source_access = True

Table Of Contents

Previous topic

ModuleLoader Class

Next topic

PrefixLoader Class