# HG changeset patch # User Johannes Bornhold # Date 2016-05-24 13:38:02 # Node ID 91f51a05ae807d1743392644603d46d177897e43 # Parent bc0e5600e6890ddd743f9c13ead332ec3d290373 pyramid: Fix problem with adding '_' to renderer globals. - Problem occures only when executing pyramid views. diff --git a/rhodecode/subscribers.py b/rhodecode/subscribers.py --- a/rhodecode/subscribers.py +++ b/rhodecode/subscribers.py @@ -21,6 +21,7 @@ import pylons from pyramid.i18n import get_localizer, TranslationStringFactory +from pyramid.threadlocal import get_current_request tsf = TranslationStringFactory('rc_root') @@ -33,8 +34,11 @@ def add_renderer_globals(event): event['c'] = pylons.tmpl_context event['url'] = pylons.url + # TODO: When executed in pyramid view context the request is not available + # in the event. Find a better solution to get the request. + request = event['request'] or get_current_request() + # Add Pyramid translation as '_' to context - request = event['request'] event['_'] = request.translate event['localizer'] = request.localizer