From 26d1f8ea5cf82ff0cb541356a74e3b38b59b69b7 Mon Sep 17 00:00:00 2001 From: Johannes Bornhold Date: Tue, 24 May 2016 15:38:02 +0200 Subject: [PATCH] pyramid: Fix problem with adding '_' to renderer globals. - Problem occures only when executing pyramid views. --- rhodecode/subscribers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rhodecode/subscribers.py b/rhodecode/subscribers.py index 6ef8308e..6ba40063 100644 --- 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