cherrypy.request.tg_template_enginename

Here are the examples of the python api cherrypy.request.tg_template_enginename taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

0 Source : flask_util.py
with GNU General Public License v2.0
from StykMartin

def render_tg_template(template_name, data):
    """
    Helper for Flask handlers to render a Kid template in 
    a TurboGears-compatible way. This reimplements the bare minimum TG magic 
    bits needed to successfully render a template inheriting from master.kid.
    """
    from turbogears.view import render
    # These are the widgets which are always included on every page (as defined 
    # in tg.include_widgets) minus Mochikit because we are not using that in any 
    # new code.
    from bkr.server.widgets import jquery, beaker_js, beaker_css
    data['tg_css'] = beaker_css.retrieve_css()
    data['tg_js_head'] = jquery.retrieve_javascript() + beaker_js.retrieve_javascript()
    data['tg_js_bodytop'] = []
    data['tg_js_bodybottom'] = []
    # If the worker has previously handled a CherryPy request then 
    # cherrypy.request will be left behind from that, and 
    # turbogears.util.request_available will be fooled into thinking we are 
    # actually inside CherryPy. The base implementation of 
    # turbogears.widgets.Widget#display tries to check tg_template_enginename if 
    # it thinks a CherryPy request is available, so we just set it here to 
    # avoid AttributeErrors in that code (since we really aren't inside 
    # a CherryPy request at this point).
    import cherrypy
    try:
        cherrypy.request.tg_template_enginename = 'kid'
    except AttributeError:
        pass
    return render(data, template_name)

# Error handling helpers that play nice with the Beaker CLI.
# These report HTTP errors as plain text responses containing just the
# error message details, which the client then intercepts and displays as
# the error message for a failed command.

class PlainTextHTTPException(HTTPException):