Example #1
0
    def __init__(self, app):
        self.app = app
        self.debug_toolbars = None
        self.hosts = ()
        loaded = web.config.get('DEBUG_TB_PANELS_LOADED')
        if loaded is None:
            web.config.DEBUG_TB_PANELS_LOADED = True
            DebugToolbar.load_panels()

        def my_processor(handler): 
            self.process_request()
            return self.process_response(handler())

        self.app.add_processor(my_processor)

        # Configure jinja for the internal templates and add url rules
        # for static data
        self.jinja_env = Environment(
            autoescape=True,
            extensions=['jinja2.ext.i18n', 'jinja2.ext.with_'],
            loader=PackageLoader(__name__, 'templates'))
        self.jinja_env.filters['urlencode'] = url_quote_plus
        self.jinja_env.filters['printable'] = _printable