def add_tosca_middleware(self, app): """Configure the ToscaWidgets middleware""" app = tw_middleware(app, { 'toscawidgets.framework.default_view': self.default_renderer, 'toscawidgets.middleware.inject_resources': True, }) return app
def add_tosca_middleware(self, app): """Configure the ToscaWidgets middleware.""" app = tw_middleware( app, { 'toscawidgets.framework.default_view': self.default_renderer, 'toscawidgets.framework.translator': ugettext, 'toscawidgets.middleware.inject_resources': True, }) return app
def add_tosca_middleware(self, app): """Configure the ToscaWidgets middleware. If you would like to override the way the TW middleware works, you might do something like:: from tg.configuration import AppConfig from tw.api import make_middleware as tw_middleware class MyAppConfig(AppConfig): def add_tosca2_middleware(self, app): app = tw_middleware(app, { 'toscawidgets.framework.default_view': self.default_renderer, 'toscawidgets.framework.translator': ugettext, 'toscawidgets.middleware.inject_resources': False, }) return app base_config = MyAppConfig() The above example would disable resource injection. There is more information about the settings you can change in the ToscaWidgets `middleware. <http://toscawidgets.org/documentation/ToscaWidgets/modules/middleware.html>` """ import tw from tw.api import make_middleware as tw_middleware twconfig = {'toscawidgets.framework.default_view': self.default_renderer, 'toscawidgets.framework.translator': ugettext, 'toscawidgets.middleware.inject_resources': True, } for k,v in config.items(): if k.startswith('toscawidgets.framework.') or k.startswith('toscawidgets.middleware.'): twconfig[k] = v if 'toscawidgets.framework.resource_variant' in config: import tw.api tw.api.resources.registry.ACTIVE_VARIANT = config['toscawidgets.framework.resource_variant'] #remove it from the middleware madness del twconfig['toscawidgets.framework.resource_variant'] app = tw_middleware(app, twconfig) if self.default_renderer in ('genshi','mako'): tw.framework.default_view = self.default_renderer return app
def add_tosca_middleware(self, app): """Configure the ToscaWidgets middleware. If you would like to override the way the TW middleware works, you might do something like:: from tg.configuration import AppConfig from tw.api import make_middleware as tw_middleware class MyAppConfig(AppConfig): def add_tosca2_middleware(self, app): app = tw_middleware(app, { 'toscawidgets.framework.default_view': self.default_renderer, 'toscawidgets.framework.translator': ugettext, 'toscawidgets.middleware.inject_resources': False, }) return app base_config = MyAppConfig() The above example would disable resource injection. There is more information about the settings you can change in the ToscaWidgets `middleware. <http://toscawidgets.org/documentation/ToscaWidgets/modules/middleware.html>` """ from tw.api import make_middleware as tw_middleware twconfig = {'toscawidgets.framework.default_view': self.default_renderer, 'toscawidgets.framework.translator': ugettext, 'toscawidgets.middleware.inject_resources': True, } for k,v in config.iteritems(): if k.startswith('toscawidgets.framework.') or k.startswith('toscawidgets.middleware.'): twconfig[k] = v if 'toscawidgets.framework.resource_variant' in config: import tw.api tw.api.resources.registry.ACTIVE_VARIANT = config['toscawidgets.framework.resource_variant'] #remove it from the middleware madness del twconfig['toscawidgets.framework.resource_variant'] app = tw_middleware(app, twconfig) return app