예제 #1
0
def renderer_factory(info):
    """
    Factory to produce renderers. Intended to be used with asset specs.

    .. note:: At this time, this does not support the pyramid 1.4 macro syntax.
    """
    return template_renderer_factory(info, ZPTTemplateRenderer)
예제 #2
0
def render_template_to_response(path, **kw):
    """Render template to response considering redirect flag.
    """
    kw = _update_kw(**kw)
    kw['request'].environ['redirect'] = None
    info = RendererHelper(name=path, registry=kw['request'].registry)
    renderer = template_renderer_factory(info, ZPTTemplateRenderer)
    result = renderer(kw, {})
    if _redirect(kw):
        redirect = kw['request'].environ['redirect']
        if isinstance(redirect, HTTPFound):
            return redirect
        return HTTPFound(location=redirect)
    response_factory = kw['request'].registry.queryUtility(
        IResponseFactory,
        default=Response)
    return response_factory(result)
예제 #3
0
def render_template(path, **kw):
    """Render template considering redirect flag.
    """
    kw = _update_kw(**kw)
    if _redirect(kw):
        return u''
    if not (':' in path or os.path.isabs(path)):
        raise ValueError('Relative path not supported: {}'.format(path))
    info = RendererHelper(name=path, registry=kw['request'].registry)
    renderer = template_renderer_factory(info, ZPTTemplateRenderer)
    try:
        return renderer(kw, {})
    except Exception:
        etype, value, tb = sys.exc_info()
        msg = 'Error while rendering tile template.\n{}'.format(
            ''.join(traceback.format_exception(etype, value, tb))
        )
        logger = kw['request'].registry.getUtility(IDebugLogger)
        logger.debug(msg)
        raise
예제 #4
0
파일: zpt.py 프로젝트: bmonteiro00/geru
def renderer_factory(info):
    return renderer.template_renderer_factory(info, ZPTTemplateRenderer)
예제 #5
0
def renderer_factory(info):
    return renderer.template_renderer_factory(info, TextTemplateRenderer)
예제 #6
0
 def _callFUT(self, info, impl):
     from pyramid_chameleon.renderer import template_renderer_factory
     return template_renderer_factory(info, impl)
예제 #7
0
파일: prefix.py 프로젝트: eugeneai/rdfrep
def renderer_factory(info):
    return renderer.template_renderer_factory(info, MyZPTTemplateRenderer)
예제 #8
0
def renderer_factory(info):
    info.name = convert_path(info.name, info.registry.settings)
    return renderer.template_renderer_factory(info, ZPTTemplateRenderer)
def renderer_factory(info):
    return template_renderer_factory(info, ZPTTemplateRenderer)