Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 4
0
def renderer_factory(info):
    return renderer.template_renderer_factory(info, ZPTTemplateRenderer)
Exemplo n.º 5
0
def renderer_factory(info):
    return renderer.template_renderer_factory(info, TextTemplateRenderer)
Exemplo n.º 6
0
 def _callFUT(self, info, impl):
     from pyramid_chameleon.renderer import template_renderer_factory
     return template_renderer_factory(info, impl)
Exemplo n.º 7
0
def renderer_factory(info):
    return renderer.template_renderer_factory(info, MyZPTTemplateRenderer)
Exemplo n.º 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)