pyramid: allows easier turning off the pylons components.
This commit is contained in:
parent
26fd27cd8c
commit
ebc5609e99
4 changed files with 20 additions and 9 deletions
|
|
@ -124,8 +124,12 @@ class BaseAppView(object):
|
|||
|
||||
# TODO(marcink): remove once pyramid migration is finished
|
||||
from pylons import tmpl_context as c
|
||||
for k, v in tmpl_args.items():
|
||||
setattr(c, k, v)
|
||||
try:
|
||||
for k, v in tmpl_args.items():
|
||||
setattr(c, k, v)
|
||||
except TypeError:
|
||||
log.exception('Failed to register pylons C')
|
||||
pass
|
||||
|
||||
def _get_template_context(self, tmpl_args):
|
||||
self._register_global_c(tmpl_args)
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ def includeme(config):
|
|||
config.add_notfound_view(make_not_found_view(config))
|
||||
|
||||
if not settings.get('debugtoolbar.enabled', False):
|
||||
# if no toolbar, then any exception gets caught and rendered
|
||||
# disabled debugtoolbar handle all exceptions via the error_handlers
|
||||
config.add_view(error_handler, context=Exception)
|
||||
|
||||
config.add_view(error_handler, context=HTTPError)
|
||||
|
|
@ -388,9 +388,13 @@ def wrap_app_in_wsgi_middlewares(pyramid_app, config):
|
|||
|
||||
# Add RoutesMiddleware to support the pylons compatibility tween during
|
||||
# migration to pyramid.
|
||||
pyramid_app = SkippableRoutesMiddleware(
|
||||
pyramid_app, config.registry._pylons_compat_config['routes.map'],
|
||||
skip_prefixes=(STATIC_FILE_PREFIX, '/_debug_toolbar'))
|
||||
|
||||
# TODO(marcink): remove after migration to pyramid
|
||||
if hasattr(config.registry, '_pylons_compat_config'):
|
||||
routes_map = config.registry._pylons_compat_config['routes.map']
|
||||
pyramid_app = SkippableRoutesMiddleware(
|
||||
pyramid_app, routes_map,
|
||||
skip_prefixes=(STATIC_FILE_PREFIX, '/_debug_toolbar'))
|
||||
|
||||
pyramid_app, _ = wrap_in_appenlight_if_enabled(pyramid_app, settings)
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ from pygments.formatters.html import HtmlFormatter
|
|||
from pygments import highlight as code_highlight
|
||||
from pygments.lexers import (
|
||||
get_lexer_by_name, get_lexer_for_filename, get_lexer_for_mimetype)
|
||||
from pylons import url as pylons_url
|
||||
from pylons.i18n.translation import _, ungettext
|
||||
from pyramid.threadlocal import get_current_request
|
||||
|
||||
|
|
@ -94,6 +93,7 @@ DEFAULT_USER_EMAIL = User.DEFAULT_USER_EMAIL
|
|||
|
||||
|
||||
def url(*args, **kw):
|
||||
from pylons import url as pylons_url
|
||||
return pylons_url(*args, **kw)
|
||||
|
||||
|
||||
|
|
@ -103,6 +103,7 @@ def pylons_url_current(*args, **kw):
|
|||
path so that it will also work from a pyramid only context. This
|
||||
should be removed once port to pyramid is complete.
|
||||
"""
|
||||
from pylons import url as pylons_url
|
||||
if not args and not kw:
|
||||
request = get_current_request()
|
||||
return request.path
|
||||
|
|
|
|||
|
|
@ -232,8 +232,10 @@ def write_js_routes_if_enabled(event):
|
|||
|
||||
def get_routes():
|
||||
# pylons routes
|
||||
for route in rhodecode.CONFIG['routes.map'].jsroutes():
|
||||
yield route
|
||||
# TODO(marcink): remove when pyramid migration is finished
|
||||
if 'routes.map' in rhodecode.CONFIG:
|
||||
for route in rhodecode.CONFIG['routes.map'].jsroutes():
|
||||
yield route
|
||||
|
||||
# pyramid routes
|
||||
for route in mapper.get_routes():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue