当前位置: 首页>>代码示例>>Python>>正文


Python template.module方法代码示例

本文整理汇总了Python中mako.template.module方法的典型用法代码示例。如果您正苦于以下问题:Python template.module方法的具体用法?Python template.module怎么用?Python template.module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mako.template的用法示例。


在下文中一共展示了template.module方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def __init__(
        self,
        name,
        context,
        module,
        callables=None,
        inherits=None,
        populate_self=True,
        calling_uri=None,
    ):
        self.name = name
        self.context = context
        self.inherits = inherits
        if callables is not None:
            self.callables = dict([(c.__name__, c) for c in callables])

        mod = __import__(module)
        for token in module.split(".")[1:]:
            mod = getattr(mod, token)
        self.module = mod 
开发者ID:remg427,项目名称:misp42splunk,代码行数:22,代码来源:runtime.py

示例2: __init__

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def __init__(self, name, context, template=None, templateuri=None,
                 callables=None, inherits=None,
                 populate_self=True, calling_uri=None):
        self.name = name
        self.context = context
        self.inherits = inherits
        if callables is not None:
            self.callables = dict([(c.__name__, c) for c in callables])

        if templateuri is not None:
            self.template = _lookup_template(context, templateuri,
                                             calling_uri)
            self._templateuri = self.template.module._template_uri
        elif template is not None:
            self.template = template
            self._templateuri = template.module._template_uri
        else:
            raise TypeError("'template' argument is required.")

        if populate_self:
            lclcallable, lclcontext = \
                _populate_self_namespace(context, self.template,
                                         self_ns=self) 
开发者ID:jpush,项目名称:jbox,代码行数:25,代码来源:runtime.py

示例3: __getattr__

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def __getattr__(self, key):
        ns = self.__parent
        while ns:
            if hasattr(ns.module, key):
                return getattr(ns.module, key)
            else:
                ns = ns.inherits
        raise AttributeError(key) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:10,代码来源:runtime.py

示例4: attr

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def attr(self):
        """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 _NSAttr(self) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:17,代码来源:runtime.py

示例5: module

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def module(self):
        """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.

        """
        return self.template.module 
开发者ID:remg427,项目名称:misp42splunk,代码行数:11,代码来源:runtime.py

示例6: filename

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def filename(self):
        """The path of the filesystem file used for this
        :class:`.Namespace`'s module or template.
        """
        return self.template.filename 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:runtime.py

示例7: _get_star

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def _get_star(self):
        if self.callables:
            for key in self.callables:
                yield (key, self.callables[key])
        for key in dir(self.module):
            if key[0] != "_":
                callable_ = getattr(self.module, key)
                if callable(callable_):
                    yield key, functools.partial(callable_, self.context) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:11,代码来源:runtime.py

示例8: _inherit_from

# 需要导入模块: from mako import template [as 别名]
# 或者: from mako.template import module [as 别名]
def _inherit_from(context, uri, calling_uri):
    """called by the _inherit method in template modules to set
    up the inheritance chain at the start of a template's
    execution."""

    if uri is None:
        return None
    template = _lookup_template(context, uri, calling_uri)
    self_ns = context["self"]
    ih = self_ns
    while ih.inherits is not None:
        ih = ih.inherits
    lclcontext = context._locals({"next": ih})
    ih.inherits = TemplateNamespace(
        "self:%s" % template.uri,
        lclcontext,
        template=template,
        populate_self=False,
    )
    context._data["parent"] = lclcontext._data["local"] = ih.inherits
    callable_ = getattr(template.module, "_mako_inherit", None)
    if callable_ is not None:
        ret = callable_(template, lclcontext)
        if ret:
            return ret

    gen_ns = getattr(template.module, "_mako_generate_namespaces", None)
    if gen_ns is not None:
        gen_ns(context)
    return (template.callable_, lclcontext) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:32,代码来源:runtime.py


注:本文中的mako.template.module方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。