pyramid: Fix problem with adding '_' to renderer globals.
- Problem occures only when executing pyramid views.
This commit is contained in:
parent
faab12bfec
commit
26d1f8ea5c
1 changed files with 5 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue