v. 0.2.4:
[django-ssify.git] / ssify / variables.py
index e969450..014e95f 100644 (file)
@@ -11,7 +11,8 @@ at request time to the prerendered templates.
 """
 from __future__ import unicode_literals
 from hashlib import md5
 """
 from __future__ import unicode_literals
 from hashlib import md5
-from django import template
+from django.template import Node
+from django.template.base import get_library
 from django.utils.encoding import force_text, python_2_unicode_compatible
 from django.utils.functional import Promise
 from django.utils.safestring import mark_safe
 from django.utils.encoding import force_text, python_2_unicode_compatible
 from django.utils.functional import Promise
 from django.utils.safestring import mark_safe
@@ -72,7 +73,7 @@ class SsiVariable(object):
     def get_value(self, request):
         """Computes the real value of the variable, using the request."""
         taglib, tagname = self.tagpath.rsplit('.', 1)
     def get_value(self, request):
         """Computes the real value of the variable, using the request."""
         taglib, tagname = self.tagpath.rsplit('.', 1)
-        return template.get_library(taglib).tags[tagname].get_value(
+        return get_library(taglib).tags[tagname].get_value(
             request, *self.args, **self.kwargs)
 
     def __str__(self):
             request, *self.args, **self.kwargs)
 
     def __str__(self):
@@ -117,13 +118,13 @@ def ssi_expect(var, type_):
         return type_(var)
 
 
         return type_(var)
 
 
-class SsiVariableNode(template.Node):
+class SsiVariableNode(Node):
     """ Node for the SsiVariable tags. """
     """ Node for the SsiVariable tags. """
-    def __init__(self, tagpath, args, kwargs, vary=None, asvar=None):
+    def __init__(self, tagpath, args, kwargs, patch_response=None, asvar=None):
         self.tagpath = tagpath
         self.args = args
         self.kwargs = kwargs
         self.tagpath = tagpath
         self.args = args
         self.kwargs = kwargs
-        self.vary = vary
+        self.patch_response = patch_response
         self.asvar = asvar
 
     def __repr__(self):
         self.asvar = asvar
 
     def __repr__(self):
@@ -137,9 +138,13 @@ class SsiVariableNode(template.Node):
         var = SsiVariable(self.tagpath, resolved_args, resolved_kwargs)
 
         request = context['request']
         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
         request.ssi_vars_needed[var.name] = var
-        if self.vary:
-            request.ssi_vary.update(self.vary)
+        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:
             context.dicts[0][self.asvar] = var
 
         if self.asvar:
             context.dicts[0][self.asvar] = var