Ticket #18260: cachetag.diff
File cachetag.diff, 1.6 KB (added by , 13 years ago) |
---|
-
django/templatetags/cache.py
old new 9 9 class CacheNode(Node): 10 10 def __init__(self, nodelist, expire_time_var, fragment_name, vary_on): 11 11 self.nodelist = nodelist 12 self.expire_time_var = Variable(expire_time_var)12 self.expire_time_var = expire_time_var 13 13 self.fragment_name = fragment_name 14 14 self.vary_on = vary_on 15 15 … … 23 23 except (ValueError, TypeError): 24 24 raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time) 25 25 # Build a unicode key for this fragment and all vary-on's. 26 args = hashlib.md5(u':'.join([urlquote( resolve_variable(var,context)) for var in self.vary_on]))27 cache_key = 'template.cache.%s.%s' % (self.fragment_name , args.hexdigest())26 args = hashlib.md5(u':'.join([urlquote(var.resolve(context)) for var in self.vary_on])) 27 cache_key = 'template.cache.%s.%s' % (self.fragment_name.resolve(context), args.hexdigest()) 28 28 value = cache.get(cache_key) 29 29 if value is None: 30 30 value = self.nodelist.render(context) … … 55 55 """ 56 56 nodelist = parser.parse(('endcache',)) 57 57 parser.delete_first_token() 58 tokens = token.contents.split()58 tokens = [parser.compile_filter(token) for token in token.contents.split()] 59 59 if len(tokens) < 3: 60 60 raise TemplateSyntaxError(u"'%r' tag requires at least 2 arguments." % tokens[0]) 61 61 return CacheNode(nodelist, tokens[1], tokens[2], tokens[3:])