Pārlūkot izejas kodu

HUE-8905 [core] Apply HUE-8772 to Django-1.11.22 for fixing 'user is missing in mako context'

Ying Chen 6 gadi atpakaļ
vecāks
revīzija
cf717de5cd

+ 27 - 2
desktop/core/ext-py/Django-1.11.22/django/template/context.py

@@ -228,6 +228,25 @@ class RenderContext(BaseContext):
                 self.pop()
 
 
+from django.utils.module_loading import import_string
+_standard_context_processors = None
+
+# This is a function rather than module-level procedural code because we only
+# want it to execute if somebody uses RequestContext.
+def get_standard_processors():
+    from django.conf import settings
+    global _standard_context_processors
+    if _standard_context_processors is None:
+        processors = []
+        collect = []
+        collect.extend(_builtin_context_processors)
+        collect.extend(settings.GTEMPLATE_CONTEXT_PROCESSORS)
+        for path in collect:
+            func = import_string(path)
+            processors.append(func)
+        _standard_context_processors = tuple(processors)
+    return _standard_context_processors
+
 class RequestContext(Context):
     """
     This subclass of template.Context automatically populates itself using
@@ -242,12 +261,18 @@ class RequestContext(Context):
         self._processors = () if processors is None else tuple(processors)
         self._processors_index = len(self.dicts)
 
+        updates = dict()
+        #@TODO@ Prakash to Implement context processor
+        for processor in get_standard_processors():
+            updates.update(processor(request))
+        self.update(updates)
+
         # placeholder for context processors output
-        self.update({})
+        #self.update({})
 
         # empty dict for any new modifications
         # (so that context processors don't overwrite them)
-        self.update({})
+        #self.update({})
 
     @contextmanager
     def bind_template(self, template):