class Namespace: (source)
Known subclasses: mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
Provides access to collections of rendering methods, which can be local, from other templates, or from imported modules. To access a particular rendering method referenced by a :class:`.Namespace`, use plain attribute access: .. sourcecode:: mako ${some_namespace.foo(x, y, z)} :class:`.Namespace` also contains several built-in attributes described here.
Method | __getattr__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | get |
Return a value from the :class:`.Cache` referenced by this :class:`.Namespace` object's :class:`.Template`. |
Method | get |
Return a :class:`.Namespace` corresponding to the given ``uri``. |
Method | get |
Return a :class:`.Template` from the given ``uri``. |
Method | include |
Include a file at the given ``uri``. |
Class Variable | filename |
The path of the filesystem file used for this :class:`.Namespace`'s module or template. |
Class Variable | module |
The Python module referenced by this :class:`.Namespace`. |
Class Variable | template |
The :class:`.Template` object referenced by this :class:`.Namespace`, if any. |
Class Variable | uri |
The URI for this :class:`.Namespace`'s template. |
Instance Variable | callables |
Undocumented |
Instance Variable | context |
The :class:`.Context` object for this :class:`.Namespace`. |
Instance Variable | inherits |
Undocumented |
Instance Variable | name |
Undocumented |
Property | attr |
Access module level attributes by name. |
Property | cache |
Return the :class:`.Cache` object referenced by this :class:`.Namespace` object's :class:`.Template`. |
Method | _get |
Undocumented |
Method | _populate |
Undocumented |
Class Variable | _templateuri |
Undocumented |
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
Undocumented
Return a value from the :class:`.Cache` referenced by this :class:`.Namespace` object's :class:`.Template`. The advantage to this method versus direct access to the :class:`.Cache` is that the configuration parameters declared in ``<%page>`` take effect here, thereby calling up the same configured backend as that configured by ``<%page>``.
Return a :class:`.Namespace` corresponding to the given ``uri``. If the given ``uri`` is a relative URI (i.e. it does not contain a leading slash ``/``), the ``uri`` is adjusted to be relative to the ``uri`` of the namespace itself. This method is therefore mostly useful off of the built-in ``local`` namespace, described in :ref:`namespace_local`. In most cases, a template wouldn't need this function, and should instead use the ``<%namespace>`` tag to load namespaces. However, since all ``<%namespace>`` tags are evaluated before the body of a template ever runs, this method can be used to locate namespaces using expressions that were generated within the body code of the template, or to conditionally use a particular namespace.
Return a :class:`.Template` from the given ``uri``. The ``uri`` resolution is relative to the ``uri`` of this :class:`.Namespace` object's :class:`.Template`.
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
The path of the filesystem file used for this :class:`.Namespace`'s module or template. If this is a pure module-based :class:`.Namespace`, this evaluates to ``module.__file__``. If a template-based namespace, it evaluates to the original template file location.
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
The Python module referenced by this :class:`.Namespace`. If the namespace references a :class:`.Template`, then this module is the equivalent of ``template.module``, i.e. the generated module for the template.
mako.runtime.TemplateNamespace
The :class:`.Template` object referenced by this :class:`.Namespace`, if any.
mako.runtime.TemplateNamespace
The URI for this :class:`.Namespace`'s template. I.e. whatever was sent to :meth:`.TemplateLookup.get_template()`. This is the equivalent of :attr:`.Template.uri`.
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
The :class:`.Context` object for this :class:`.Namespace`. Namespaces are often created with copies of contexts that contain slightly different data, particularly in inheritance scenarios. Using the :class:`.Context` off of a :class:`.Namespace` one can traverse an entire chain of templates that inherit from one-another.
Access module level attributes by name. This accessor allows templates to supply "scalar" attributes which are particularly handy in inheritance relationships. .. seealso:: :ref:`inheritance_attr` :ref:`namespace_attr_for_includes`
Return the :class:`.Cache` object referenced by this :class:`.Namespace` object's :class:`.Template`.