##// END OF EJS Templates
pyramid: allows easier turning off the pylons components.
marcink -
r1912:f0e0aac6 default
parent child Browse files
Show More
@@ -124,8 +124,12 b' class BaseAppView(object):'
124
124
125 # TODO(marcink): remove once pyramid migration is finished
125 # TODO(marcink): remove once pyramid migration is finished
126 from pylons import tmpl_context as c
126 from pylons import tmpl_context as c
127 for k, v in tmpl_args.items():
127 try:
128 setattr(c, k, v)
128 for k, v in tmpl_args.items():
129 setattr(c, k, v)
130 except TypeError:
131 log.exception('Failed to register pylons C')
132 pass
129
133
130 def _get_template_context(self, tmpl_args):
134 def _get_template_context(self, tmpl_args):
131 self._register_global_c(tmpl_args)
135 self._register_global_c(tmpl_args)
@@ -345,7 +345,7 b' def includeme(config):'
345 config.add_notfound_view(make_not_found_view(config))
345 config.add_notfound_view(make_not_found_view(config))
346
346
347 if not settings.get('debugtoolbar.enabled', False):
347 if not settings.get('debugtoolbar.enabled', False):
348 # if no toolbar, then any exception gets caught and rendered
348 # disabled debugtoolbar handle all exceptions via the error_handlers
349 config.add_view(error_handler, context=Exception)
349 config.add_view(error_handler, context=Exception)
350
350
351 config.add_view(error_handler, context=HTTPError)
351 config.add_view(error_handler, context=HTTPError)
@@ -388,9 +388,13 b' def wrap_app_in_wsgi_middlewares(pyramid'
388
388
389 # Add RoutesMiddleware to support the pylons compatibility tween during
389 # Add RoutesMiddleware to support the pylons compatibility tween during
390 # migration to pyramid.
390 # migration to pyramid.
391 pyramid_app = SkippableRoutesMiddleware(
391
392 pyramid_app, config.registry._pylons_compat_config['routes.map'],
392 # TODO(marcink): remove after migration to pyramid
393 skip_prefixes=(STATIC_FILE_PREFIX, '/_debug_toolbar'))
393 if hasattr(config.registry, '_pylons_compat_config'):
394 routes_map = config.registry._pylons_compat_config['routes.map']
395 pyramid_app = SkippableRoutesMiddleware(
396 pyramid_app, routes_map,
397 skip_prefixes=(STATIC_FILE_PREFIX, '/_debug_toolbar'))
394
398
395 pyramid_app, _ = wrap_in_appenlight_if_enabled(pyramid_app, settings)
399 pyramid_app, _ = wrap_in_appenlight_if_enabled(pyramid_app, settings)
396
400
@@ -48,7 +48,6 b' from pygments.formatters.html import Htm'
48 from pygments import highlight as code_highlight
48 from pygments import highlight as code_highlight
49 from pygments.lexers import (
49 from pygments.lexers import (
50 get_lexer_by_name, get_lexer_for_filename, get_lexer_for_mimetype)
50 get_lexer_by_name, get_lexer_for_filename, get_lexer_for_mimetype)
51 from pylons import url as pylons_url
52 from pylons.i18n.translation import _, ungettext
51 from pylons.i18n.translation import _, ungettext
53 from pyramid.threadlocal import get_current_request
52 from pyramid.threadlocal import get_current_request
54
53
@@ -94,6 +93,7 b' DEFAULT_USER_EMAIL = User.DEFAULT_USER_E'
94
93
95
94
96 def url(*args, **kw):
95 def url(*args, **kw):
96 from pylons import url as pylons_url
97 return pylons_url(*args, **kw)
97 return pylons_url(*args, **kw)
98
98
99
99
@@ -103,6 +103,7 b' def pylons_url_current(*args, **kw):'
103 path so that it will also work from a pyramid only context. This
103 path so that it will also work from a pyramid only context. This
104 should be removed once port to pyramid is complete.
104 should be removed once port to pyramid is complete.
105 """
105 """
106 from pylons import url as pylons_url
106 if not args and not kw:
107 if not args and not kw:
107 request = get_current_request()
108 request = get_current_request()
108 return request.path
109 return request.path
@@ -232,8 +232,10 b' def write_js_routes_if_enabled(event):'
232
232
233 def get_routes():
233 def get_routes():
234 # pylons routes
234 # pylons routes
235 for route in rhodecode.CONFIG['routes.map'].jsroutes():
235 # TODO(marcink): remove when pyramid migration is finished
236 yield route
236 if 'routes.map' in rhodecode.CONFIG:
237 for route in rhodecode.CONFIG['routes.map'].jsroutes():
238 yield route
237
239
238 # pyramid routes
240 # pyramid routes
239 for route in mapper.get_routes():
241 for route in mapper.get_routes():
General Comments 0
You need to be logged in to leave comments. Login now