Esempio n. 1
0
def render_template(path, **kw):
    kw = _update_kw(**kw)
    if _redirect(kw):
        return u''
    if not (':' in path or os.path.isabs(path)): 
        raise ValueError, 'Relative path not supported: %s' % path
    info = RendererHelper(name=path, registry=kw['request'].registry)
    renderer = template_renderer_factory(info, ZPTTemplateRenderer)
    return renderer(kw, {})    
Esempio n. 2
0
def render_template_to_response(path, **kw):
    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):
        return HTTPFound(location=kw['request'].environ['redirect'])
    response_factory = kw['request'].registry.queryUtility(IResponseFactory,
                                                           default=Response)
    return response_factory(result)
Esempio n. 3
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)
Esempio n. 4
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: %s' % path
    info = RendererHelper(name=path, registry=kw['request'].registry)
    renderer = template_renderer_factory(info, ZPTTemplateRenderer)
    try:
        return renderer(kw, {})
    except Exception, exc:
        log_exception('Error while rendering tile template.', exc,
                      sys.exc_traceback)
        raise
Esempio n. 5
0
def renderer_factory(info):
    return renderers.template_renderer_factory(info, ZPTTemplateRenderer)
Esempio n. 6
0
 def _callFUT(self, info, impl):
     from pyramid.renderers import template_renderer_factory
     return template_renderer_factory(info, impl)
Esempio n. 7
0
 def _callFUT(self, info, impl):
     from pyramid.renderers import template_renderer_factory
     return template_renderer_factory(info, impl)
Esempio n. 8
0
def renderer_factory(info, lock=registry_lock):
    return renderers.template_renderer_factory(info, ZPTTemplateRenderer)
Esempio n. 9
0
def renderer_factory(path):
    return renderers.template_renderer_factory(path, TextTemplateRenderer)
Esempio n. 10
0
def renderer_factory(info):
    # TODO: this is an internal API? maybe we should use a better way
    # to deal with it
    return renderers.template_renderer_factory(info, GenshiTemplateRenderer)
Esempio n. 11
0
def renderer_factory(info):
    return renderers.template_renderer_factory(info, TextTemplateRenderer)
Esempio n. 12
0
 def _callFUT(self, path, factory):
     from pyramid.renderers import template_renderer_factory
     return template_renderer_factory(path, factory)
Esempio n. 13
0
def renderer_factory(info):
    # TODO: this is an internal API? maybe we should use a better way
    # to deal with it
    return renderers.template_renderer_factory(info, GenshiTemplateRenderer)
Esempio n. 14
0
def renderer_factory(path):
    return renderers.template_renderer_factory(path, GenshiTemplateRenderer)
Esempio n. 15
0
 def _callFUT(self, path, factory):
     from pyramid.renderers import template_renderer_factory
     return template_renderer_factory(path, factory)
Esempio n. 16
0
def renderer_factory(info, lock=registry_lock):
    return renderers.template_renderer_factory(info, ZPTTemplateRenderer)