class Namespace(object):
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
.Namespace
, use plain attribute access:
${some_namespace.foo(x, y, z)}
.Namespace
also contains several built-in attributes
described here.
Method | get_cached |
Return a value from the .Cache referenced by this .Namespace object's .Template . |
Method | get_namespace |
Return a .Namespace corresponding to the given uri. |
Method | get_template |
Return a .Template from the given uri. |
Method | include_file |
Include a file at the given uri. |
Class Variable | filename |
The path of the filesystem file used for this .Namespace 's module or template. |
Class Variable | module |
The Python module referenced by this .Namespace . |
Class Variable | template |
The .Template object referenced by this .Namespace , if any. |
Class Variable | uri |
The URI for this .Namespace 's template. |
Instance Variable | context |
The .Context object for this .Namespace . |
Method | __getattr__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | _get_star |
Undocumented |
Method | _populate |
Undocumented |
Class Variable | _templateuri |
Undocumented |
Instance Variable | callables |
Undocumented |
Instance Variable | inherits |
Undocumented |
Instance Variable | name |
Undocumented |
Property | attr |
Access module level attributes by name. |
Property | cache |
Return the .Cache object referenced by this .Namespace object's .Template . |
Return a value from the .Cache
referenced by this
.Namespace
object's .Template
.
The advantage to this method versus direct access to the
.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 .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 .Template
from the given uri.
The uri resolution is relative to the uri of this
.Namespace
object's .Template
.
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
The path of the filesystem file used for this
.Namespace
's module or template.
If this is a pure module-based
.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 .Namespace
.
If the namespace references a .Template
, then
this module is the equivalent of template.module,
i.e. the generated module for the template.
mako.runtime.TemplateNamespace
.Template
object referenced by this
.Namespace
, if any.mako.runtime.TemplateNamespace
The URI for this .Namespace
's template.
I.e. whatever was sent to .TemplateLookup.get_template()
.
This is the equivalent of .Template.uri
.
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
The .Context
object for this .Namespace
.
Namespaces are often created with copies of contexts that
contain slightly different data, particularly in inheritance
scenarios. Using the .Context
off of a .Namespace
one
can traverse an entire chain of templates that inherit from
one-another.
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
Undocumented
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
Undocumented
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
Undocumented
tuple
=
mako.runtime.ModuleNamespace
, mako.runtime.TemplateNamespace
Undocumented