當前位置: 首頁>>代碼示例>>Python>>正文


Python template.uri方法代碼示例

本文整理匯總了Python中mako.template.uri方法的典型用法代碼示例。如果您正苦於以下問題:Python template.uri方法的具體用法?Python template.uri怎麽用?Python template.uri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mako.template的用法示例。


在下文中一共展示了template.uri方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _include_file

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def _include_file(context, uri, calling_uri, **kwargs):
    """locate the template from the given uri and include it in
    the current output."""

    template = _lookup_template(context, uri, calling_uri)
    (callable_, ctx) = _populate_self_namespace(
        context._clean_inheritance_tokens(), template
    )
    kwargs = _kwargs_for_include(callable_, context._data, **kwargs)
    if template.include_error_handler:
        try:
            callable_(ctx, **kwargs)
        except Exception:
            result = template.include_error_handler(ctx, compat.exception_as())
            if not result:
                compat.reraise(*sys.exc_info())
    else:
        callable_(ctx, **kwargs) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:20,代碼來源:runtime.py

示例2: _include_file

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def _include_file(context, uri, calling_uri, **kwargs):
    """locate the template from the given uri and include it in
    the current output."""

    template = _lookup_template(context, uri, calling_uri)
    (callable_, ctx) = _populate_self_namespace(
        context._clean_inheritance_tokens(),
        template)
    kwargs = _kwargs_for_include(callable_, context._data, **kwargs)
    if template.include_error_handler:
        try:
            callable_(ctx, **kwargs)
        except Exception:
            result = template.include_error_handler(ctx, compat.exception_as())
            if not result:
                compat.reraise(*sys.exc_info())
    else:
        callable_(ctx, **kwargs) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:20,代碼來源:runtime.py

示例3: get_namespace

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def get_namespace(self, uri):
        """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.

        """
        key = (self, uri)
        if key in self.context.namespaces:
            return self.context.namespaces[key]
        else:
            ns = TemplateNamespace(
                uri,
                self.context._copy(),
                templateuri=uri,
                calling_uri=self._templateuri,
            )
            self.context.namespaces[key] = ns
            return ns 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:34,代碼來源:runtime.py

示例4: get_template

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def get_template(self, uri):
        """Return a :class:`.Template` from the given ``uri``.

        The ``uri`` resolution is relative to the ``uri`` of this
        :class:`.Namespace` object's :class:`.Template`.

        """
        return _lookup_template(self.context, uri, self._templateuri) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:10,代碼來源:runtime.py

示例5: include_file

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def include_file(self, uri, **kwargs):
        """Include a file at the given ``uri``."""

        _include_file(self.context, uri, self._templateuri, **kwargs) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:6,代碼來源:runtime.py

示例6: uri

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def uri(self):
        """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`.

        """
        return self.template.uri 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:11,代碼來源:runtime.py

示例7: _lookup_template

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def _lookup_template(context, uri, relativeto):
    lookup = context._with_template.lookup
    if lookup is None:
        raise exceptions.TemplateLookupException(
            "Template '%s' has no TemplateLookup associated"
            % context._with_template.uri
        )
    uri = lookup.adjust_uri(uri, relativeto)
    try:
        return lookup.get_template(uri)
    except exceptions.TopLevelLookupException:
        raise exceptions.TemplateLookupException(str(compat.exception_as())) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:14,代碼來源:runtime.py

示例8: _populate_self_namespace

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def _populate_self_namespace(context, template, self_ns=None):
    if self_ns is None:
        self_ns = TemplateNamespace(
            "self:%s" % template.uri,
            context,
            template=template,
            populate_self=False,
        )
    context._data["self"] = context._data["local"] = self_ns
    if hasattr(template.module, "_mako_inherit"):
        ret = template.module._mako_inherit(template, context)
        if ret:
            return ret
    return (template.callable_, context) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:16,代碼來源:runtime.py

示例9: _inherit_from

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [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

示例10: get_namespace

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def get_namespace(self, uri):
        """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.

        """
        key = (self, uri)
        if key in self.context.namespaces:
            return self.context.namespaces[key]
        else:
            ns = TemplateNamespace(uri, self.context._copy(),
                                   templateuri=uri,
                                   calling_uri=self._templateuri)
            self.context.namespaces[key] = ns
            return ns 
開發者ID:jpush,項目名稱:jbox,代碼行數:31,代碼來源:runtime.py

示例11: _include_file

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def _include_file(context, uri, calling_uri, **kwargs):
    """locate the template from the given uri and include it in
    the current output."""

    template = _lookup_template(context, uri, calling_uri)
    (callable_, ctx) = _populate_self_namespace(
        context._clean_inheritance_tokens(),
        template)
    callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:runtime.py

示例12: _lookup_template

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def _lookup_template(context, uri, relativeto):
    lookup = context._with_template.lookup
    if lookup is None:
        raise exceptions.TemplateLookupException(
            "Template '%s' has no TemplateLookup associated" %
            context._with_template.uri)
    uri = lookup.adjust_uri(uri, relativeto)
    try:
        return lookup.get_template(uri)
    except exceptions.TopLevelLookupException:
        raise exceptions.TemplateLookupException(str(compat.exception_as())) 
開發者ID:jpush,項目名稱:jbox,代碼行數:13,代碼來源:runtime.py

示例13: _populate_self_namespace

# 需要導入模塊: from mako import template [as 別名]
# 或者: from mako.template import uri [as 別名]
def _populate_self_namespace(context, template, self_ns=None):
    if self_ns is None:
        self_ns = TemplateNamespace('self:%s' % template.uri,
                                    context, template=template,
                                    populate_self=False)
    context._data['self'] = context._data['local'] = self_ns
    if hasattr(template.module, '_mako_inherit'):
        ret = template.module._mako_inherit(template, context)
        if ret:
            return ret
    return (template.callable_, context) 
開發者ID:jpush,項目名稱:jbox,代碼行數:13,代碼來源:runtime.py


注:本文中的mako.template.uri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。