• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python templating.pylons_globals函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pylons.templating.pylons_globals函数的典型用法代码示例。如果您正苦于以下问题:Python pylons_globals函数的具体用法?Python pylons_globals怎么用?Python pylons_globals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: render_template

    def render_template():
        globs = extra_vars or {}
        globs.update(pylons_globals())

        # Using pylons.url() directly destroys the localisation stuff so
        # we remove it so any bad templates crash and burn
        del globs["url"]

        try:
            template_path, template_type = render_.template_info(template_name)
        except render_.TemplateNotFound:
            raise

        log.debug("rendering %s [%s]" % (template_path, template_type))
        if config.get("debug"):
            context_vars = globs.get("c")
            if context_vars:
                context_vars = dir(context_vars)
            debug_info = {
                "template_name": template_name,
                "template_path": template_path,
                "template_type": template_type,
                "vars": globs,
                "c_vars": context_vars,
                "renderer": renderer,
            }
            if "CKAN_DEBUG_INFO" not in request.environ:
                request.environ["CKAN_DEBUG_INFO"] = []
            request.environ["CKAN_DEBUG_INFO"].append(debug_info)

        del globs["config"]
        return render_jinja2(template_name, globs)
开发者ID:Fiware,项目名称:context.Ckan,代码行数:32,代码来源:base.py


示例2: render_template

    def render_template():
        globs = extra_vars or {}
        globs.update(pylons_globals())

        # Using pylons.url() directly destroys the localisation stuff so
        # we remove it so any bad templates crash and burn
        del globs['url']

        try:
            template_path, template_type = render_.template_info(template_name)
        except render_.TemplateNotFound:
            raise

        log.debug('rendering %s [%s]' % (template_path, template_type))
        if config.get('debug'):
            context_vars = globs.get('c')
            if context_vars:
                context_vars = dir(context_vars)
            debug_info = {'template_name': template_name,
                          'template_path': template_path,
                          'template_type': template_type,
                          'vars': globs,
                          'c_vars': context_vars,
                          'renderer': renderer}
            if 'CKAN_DEBUG_INFO' not in request.environ:
                request.environ['CKAN_DEBUG_INFO'] = []
            request.environ['CKAN_DEBUG_INFO'].append(debug_info)

        del globs['config']
        return render_jinja2(template_name, globs)
开发者ID:berlinonline,项目名称:ckan,代码行数:30,代码来源:base.py


示例3: render

def render(template_name,
           extra_vars=None,
           form_fill=None, form_errors={},
           suppress_cache=True,
           method='xhtml'):

    if suppress_cache:
        response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '0'

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs['g'] = app_globals
    globs['can'] = can
    globs['_form_errors'] = form_errors

    # Grab a template reference
    template = globs['app_globals'].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    for item in PluginImplementations(IGenshiStreamFilter):
        stream = item.filter(stream)

    return literal(stream.render(method=method, encoding=None))
开发者ID:doismellburning,项目名称:openspending,代码行数:33,代码来源:base.py


示例4: render

def render(template_name, extra_vars=None, form_fill=None, form_errors={}, suppress_cache=True, method="xhtml"):

    if suppress_cache:
        response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
        response.headers["Pragma"] = "no-cache"
        response.headers["Expires"] = "0"

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs["g"] = app_globals
    globs["can"] = can
    globs["_form_errors"] = form_errors

    # Grab a template reference
    template = globs["app_globals"].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    return literal(stream.render(method=method, encoding=None))
开发者ID:citizennerd,项目名称:openspending,代码行数:26,代码来源:base.py


示例5: render

def render(
    template_name,
    extra_vars=None,
    form_fill=None,
    form_errors={},
    cache_expire=3600,
    cache_private=False,
    method="xhtml",
):

    _setup_cache(cache_expire, cache_private)

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs["g"] = app_globals
    globs["_form_errors"] = form_errors

    # Grab a template reference
    template = globs["app_globals"].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    for item in PluginImplementations(IGenshiStreamFilter):
        stream = item.filter(stream)

    return literal(stream.render(method=method, encoding=None))
开发者ID:rgrp,项目名称:openspending,代码行数:33,代码来源:base.py


示例6: render_template

    def render_template():
        globs = extra_vars or {}
        globs.update(pylons_globals())
        globs['actions'] = model.Action

        # Using pylons.url() directly destroys the localisation stuff so
        # we remove it so any bad templates crash and burn
        del globs['url']

        try:
            template_path, template_type = render_.template_info(template_name)
        except render_.TemplateNotFound:
            template_type = 'genshi'
            template_path = ''

        # snippets should not pass the context
        # but allow for legacy genshi templates
        if renderer == 'snippet' and template_type != 'genshi':
            del globs['c']
            del globs['tmpl_context']

        log.debug('rendering %s [%s]' % (template_path, template_type))
        if config.get('debug'):
            context_vars = globs.get('c')
            if context_vars:
                context_vars = dir(context_vars)
            debug_info = {'template_name': template_name,
                          'template_path': template_path,
                          'template_type': template_type,
                          'vars': globs,
                          'c_vars': context_vars,
                          'renderer': renderer}
            if 'CKAN_DEBUG_INFO' not in request.environ:
                request.environ['CKAN_DEBUG_INFO'] = []
            request.environ['CKAN_DEBUG_INFO'].append(debug_info)

        # Jinja2 templates
        if template_type == 'jinja2':
            # We don't want to have the config in templates it should be
            # accessed via g (app_globals) as this gives us flexability such
            # as changing via database settings.
            del globs['config']
            # TODO should we raise error if genshi filters??
            return render_jinja2(template_name, globs)

        # Genshi templates
        template = globs['app_globals'].genshi_loader.load(
            template_name.encode('utf-8'), cls=loader_class
        )
        stream = template.generate(**globs)

        for item in p.PluginImplementations(p.IGenshiStreamFilter):
            stream = item.filter(stream)

        if loader_class == NewTextTemplate:
            return literal(stream.render(method="text", encoding=None))

        return literal(stream.render(method=method, encoding=None,
                                     strip_whitespace=True))
开发者ID:NeCTAR-RC,项目名称:ckan,代码行数:59,代码来源:base.py


示例7: render_template

 def render_template():
     # First, get the globals
     globs = pylons_globals()
     
     # Grab a template reference
     template = genshi_loader.load(template_name)
     
     return template.generate(**globs).render()
开发者ID:arianepaola,项目名称:tg2jython,代码行数:8,代码来源:dbmechanic.py


示例8: render_template

    def render_template():
        globs = extra_vars or {}
        globs.update(pylons_globals())
        globs["actions"] = model.Action

        # Using pylons.url() directly destroys the localisation stuff so
        # we remove it so any bad templates crash and burn
        del globs["url"]

        try:
            template_path, template_type = lib.render.template_info(template_name)
        except lib.render.TemplateNotFound:
            template_type = "genshi"
            template_path = ""

        # snippets should not pass the context
        # but allow for legacy genshi templates
        if renderer == "snippet" and template_type != "genshi":
            del globs["c"]
            del globs["tmpl_context"]

        log.debug("rendering %s [%s]" % (template_path, template_type))
        if config.get("debug"):
            context_vars = globs.get("c")
            if context_vars:
                context_vars = dir(context_vars)
            debug_info = {
                "template_name": template_name,
                "template_path": template_path,
                "template_type": template_type,
                "vars": globs,
                "c_vars": context_vars,
                "renderer": renderer,
            }
            if "CKAN_DEBUG_INFO" not in request.environ:
                request.environ["CKAN_DEBUG_INFO"] = []
            request.environ["CKAN_DEBUG_INFO"].append(debug_info)

        # Jinja2 templates
        if template_type == "jinja2":
            # We don't want to have the config in templates it should be
            # accessed via g (app_globals) as this gives us flexability such
            # as changing via database settings.
            del globs["config"]
            # TODO should we raise error if genshi filters??
            return render_jinja2(template_name, globs)

        # Genshi templates
        template = globs["app_globals"].genshi_loader.load(template_name, cls=loader_class)
        stream = template.generate(**globs)

        for item in PluginImplementations(IGenshiStreamFilter):
            stream = item.filter(stream)

        if loader_class == NewTextTemplate:
            return literal(stream.render(method="text", encoding=None))

        return literal(stream.render(method=method, encoding=None, strip_whitespace=True))
开发者ID:robert-chiniquy,项目名称:ckan,代码行数:58,代码来源:base.py


示例9: display

 def display(self, *args, **kw):
     # TODO: See if this is still necessary. Furthermore, find out which variables it actually adds.
     # Update the kwargs with the same values that are included in main templates
     # this allows us to access the following objects in widget templates:
     # ['tmpl_context', 'translator', 'session', 'ungettext', 'response', '_',
     #  'c', 'app_globals', 'g', 'url', 'h', 'request', 'helpers', 'N_', 'tg',
     #  'config']
     kw.update(pylons_globals())
     return forms.Widget.display(self, *args, **kw)
开发者ID:86me,项目名称:mediacore,代码行数:9,代码来源:__init__.py


示例10: display

 def display(self, *args, **kw):
     # Update the kwargs with the same values that are included in main templates
     # this allows us to access the following objects in widget templates:
     # ['tmpl_context', 'translator', 'session', 'ungettext', 'response', '_',
     #  'c', 'app_globals', 'g', 'url', 'h', 'request', 'helpers', 'N_', 'tg',
     #  'config']
     kw.update(_get_tg_vars())
     kw.update(pylons_globals())
     return forms.Widget.display(self, *args, **kw)
开发者ID:SergeyLashin,项目名称:mediacore,代码行数:9,代码来源:__init__.py


示例11: render_def

def render_def(template_name, name, **kwargs):
    globs = pylons_globals()
 
    if kwargs:
        globs = globs.copy()
        globs.update(kwargs)
 
    template = globs['app_globals'].mako_lookup.get_template(template_name).get_def(name)
    return literal(template.render_unicode(**globs))
开发者ID:BackupTheBerlios,项目名称:griffith-svn,代码行数:9,代码来源:base.py


示例12: render_template

    def render_template():
        # Pull in extra vars if needed
        globs = extra_vars or {}

        # Second, get the globals
        globs.update(templating.pylons_globals())

        # Grab a template reference
        template = globs['app_globals'].kajiki_loader.load(template_name)

        return literal(template(globs).render())
开发者ID:desarrollo1,项目名称:tg2env,代码行数:11,代码来源:render.py


示例13: render_template

 def render_template():
     # Pull in extra vars if needed
     globs = {}
     
     # Second, get the globals
     globs.update(pylons_globals())
     
     # Grab a template reference
     template = \
         getattr(globs['app_globals'].jinja2_env.get_template(template_name).make_module(vars=globs), name)(**kwargs)
     return template        
开发者ID:rafal-kos,项目名称:pytis,代码行数:11,代码来源:base.py


示例14: render_template

    def render_template():
        # Pull in extra vars if needed
        globs = extra_vars or {}

        # Second, get the globals
        globs.update(pylons_globals())

        # Grab a template reference
        template = \
            globs['app_globals'].pytiles_container.get_template(template_name)

        return literal(template.render(**globs))
开发者ID:emjelde,项目名称:pytiles,代码行数:12,代码来源:pylons.py


示例15: render_template

 def render_template():
     globs = extra_vars or {}
     globs.update(pylons_globals())
     globs['actions'] = model.Action
     template = globs['app_globals'].genshi_loader.load(template_name,
         cls=loader_class)
     stream = template.generate(**globs)
     
     for item in PluginImplementations(IGenshiStreamFilter):
         stream = item.filter(stream)
     
     return literal(stream.render(method=method, encoding=None))
开发者ID:AdamJensen-dk,项目名称:ckan-drupal,代码行数:12,代码来源:base.py


示例16: render

def render(template_name, tmpl_params=None, loader=None, fragment=False):
    if tmpl_params is None:
        tmpl_params = {}

    g = pylons_globals()
    tmpl_params.update(g)

    try:
        opts = g['app_globals'].breve_opts
    except AttributeError:
        opts = {}

    t = Template(tags, **opts)
    return t.render(template_name, params=tmpl_params, loader=loader, fragment=fragment)
开发者ID:katakumpo,项目名称:breve4py3,代码行数:14,代码来源:pylons_adapter.py


示例17: render_template

 def render_template():
     # Get the globals
     # Note: when running in restricted mode which of these globals are
     # to be exposed should be a lot more selective. 
     pg = pylons_globals()
     
     # Update any extra vars if needed
     if extra_vars:
         pg.update(extra_vars)
     
     # Grab a template reference
     template = pg['app_globals'].evoque_domain.get_template(
         template_name, collection=collection, raw=raw, quoting=quoting)
     return template.evoque(pg, raw=raw, quoting=quoting)
开发者ID:DamnWidget,项目名称:goliat,代码行数:14,代码来源:base.py


示例18: content

 def content(self, path):
     """Handles returning "content" files: static content shoved more or
     less verbatim into the wrapper.
     """
     # Static files need to go through Mako to e.g. set their titles and
     # generate links, but TemplateLookup will not fetch templates outside
     # its known template directories.
     # Instead, load the template manually, and use the same lookup object
     # as everything else so references to other templates can still work
     # XXX when there's a real cache mechanism, this should use it!
     lookup = config['pylons.app_globals'].mako_lookup
     template = Template(filename=path, lookup=lookup,
                         **lookup.template_args)
     return template.render_unicode(**pylons_globals())
开发者ID:encukou,项目名称:spline,代码行数:14,代码来源:main.py


示例19: render_template

    def render_template():
        # Pull in extra vars if needed
        globs = extra_vars or {}

        # Second, get the globals
        globs.update(pylons_globals())
        globs['g'] = app_globals
        globs['_form_errors'] = form_errors

        # Grab a template reference
        template = globs['app_globals'].genshi_loader.load(template_name)
        stream = template.generate(**globs)
        if form_fill is not None:
            filler = HTMLFormFiller(data=form_fill)
            stream = stream | filler

        return literal(stream.render(method=method, encoding=None))
开发者ID:jagarcias,项目名称:openspending.etl,代码行数:17,代码来源:base.py


示例20: render_template

    def render_template():
        globs = extra_vars or {}
        globs.update(pylons_globals())
        globs['actions'] = model.Action

        # Using pylons.url() or pylons.url_for() directly destroys the
        # localisation stuff so we remove it so any bad templates crash
        # and burn
        del globs['url']

        template = globs['app_globals'].genshi_loader.load(template_name,
            cls=loader_class)
        stream = template.generate(**globs)
        
        for item in PluginImplementations(IGenshiStreamFilter):
            stream = item.filter(stream)
        
        return literal(stream.render(method=method, encoding=None, strip_whitespace=False))
开发者ID:icmurray,项目名称:ckan,代码行数:18,代码来源:base.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python templating.render函数代码示例发布时间:2022-05-25
下一篇:
Python session.save函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap