Don't assume request object we are passed at any point still has our custom attributes.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Mon, 22 Sep 2014 13:14:04 +0000 (15:14 +0200)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Mon, 22 Sep 2014 13:15:37 +0000 (15:15 +0200)
ssify/decorators.py
ssify/middleware.py
ssify/templatetags/ssify.py
ssify/variables.py

index b513dbe..e2ae9fe 100644 (file)
@@ -56,7 +56,7 @@ def ssi_included(view=None, use_lang=True,
                 request._cache_update_cache = False
 
                 def _check_included_vars(response):
-                    used_vars = request.ssi_vars_needed
+                    used_vars = getattr(request, 'ssi_vars_needed', {})
                     if get_ssi_vars:
                         # Remove the ssi vars that should be provided
                         # by the including view.
index 6b8b2ed..fc57eb0 100644 (file)
@@ -188,4 +188,6 @@ class LocaleMiddleware(locale.LocaleMiddleware):
             if (request.session.accessed and
                     (settings.USE_I18N or settings.USE_L10N)):
                 request.session.accessed = False
+                if not hasattr(request, 'ssi_patch_response'):
+                    request.ssi_patch_response = []
                 request.ssi_patch_response.append(ssi_vary_on_cookie)
index b0ecd04..78071d0 100644 (file)
@@ -58,11 +58,15 @@ def ssi_include(context, name_, **kwargs):
         for var in pass_vars:
             if not isinstance(var, SsiVariable):
                 var = SsiVariable(*var)
+            if not hasattr(request, 'ssi_vars_needed'):
+                request.ssi_vars_needed = {}
             request.ssi_vars_needed[var.name] = var
 
     # Remember the decorators to use on the including view.
     patch_response = getattr(view, 'ssi_patch_response', None)
     if patch_response:
+        if not hasattr(request, 'ssi_patch_response'):
+            request.ssi_patch_response = []
         request.ssi_patch_response.extend(patch_response)
 
     # Output the SSI include.
index 668bb51..46a787b 100644 (file)
@@ -137,8 +137,12 @@ class SsiVariableNode(template.Node):
         var = SsiVariable(self.tagpath, resolved_args, resolved_kwargs)
 
         request = context['request']
+        if not hasattr(request, 'ssi_vars_needed'):
+            request.ssi_vars_needed = {}
         request.ssi_vars_needed[var.name] = var
         if self.patch_response:
+            if not hasattr(request, 'ssi_patch_response'):
+                request.ssi_patch_response = []
             request.ssi_patch_response.extend(self.patch_response)
 
         if self.asvar: