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