From a9534732acca0a1add02f8262a57e71a5e019625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 6 Oct 2018 16:55:16 +0200 Subject: [PATCH] misc: add global context variables to context processor (#26634) --- wcs/context_processors.py | 6 ++++++ wcs/qommon/publisher.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wcs/context_processors.py b/wcs/context_processors.py index c2bdb3ffd..a68da8f64 100644 --- a/wcs/context_processors.py +++ b/wcs/context_processors.py @@ -16,6 +16,11 @@ from quixote import get_publisher, get_response, get_request +def get_global_context(): + pub = get_publisher() + if pub: + return pub.substitutions.get_context_variables(mode='lazy') + def publisher(request): template_base = 'wcs/base.html' if request.path.startswith('/backoffice/'): @@ -24,4 +29,5 @@ def publisher(request): 'response': get_response, 'user': lambda: get_request() and get_request().user, 'template_base': template_base, + 'global_context': get_global_context, } diff --git a/wcs/qommon/publisher.py b/wcs/qommon/publisher.py index f1f91ed88..ec249f6cb 100644 --- a/wcs/qommon/publisher.py +++ b/wcs/qommon/publisher.py @@ -1032,7 +1032,7 @@ class QommonPublisher(Publisher, object): # possible modes: # * django-condition: used to evaluate django conditions # * python-condition: used to evaluate python conditions - # * lazy: used to force lazy mode in tests + # * lazy: used to force lazy mode in tests and in context processor modes = self.get_site_option('lazy-variables-modes') if modes: return [x.strip() for x in modes.split(',')] -- 2.19.0