Projet

Général

Profil

0001-misc-add-global-context-variables-to-context-process.patch

Frédéric Péters, 06 octobre 2018 16:55

Télécharger (1,77 ko)

Voir les différences:

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(-)
wcs/context_processors.py
16 16

  
17 17
from quixote import get_publisher, get_response, get_request
18 18

  
19
def get_global_context():
20
    pub = get_publisher()
21
    if pub:
22
        return pub.substitutions.get_context_variables(mode='lazy')
23

  
19 24
def publisher(request):
20 25
    template_base = 'wcs/base.html'
21 26
    if request.path.startswith('/backoffice/'):
......
24 29
            'response': get_response,
25 30
            'user': lambda: get_request() and get_request().user,
26 31
            'template_base': template_base,
32
            'global_context': get_global_context,
27 33
            }
wcs/qommon/publisher.py
1032 1032
        # possible modes:
1033 1033
        # * django-condition: used to evaluate django conditions
1034 1034
        # * python-condition: used to evaluate python conditions
1035
        # * lazy: used to force lazy mode in tests
1035
        # * lazy: used to force lazy mode in tests and in context processor
1036 1036
        modes = self.get_site_option('lazy-variables-modes')
1037 1037
        if modes:
1038 1038
            return [x.strip() for x in modes.split(',')]
1039
-