Ticket #7460: cachetag.diff
File cachetag.diff, 1.2 KB (added by , 16 years ago) |
---|
-
django/templatetags/cache.py
5 5 6 6 register = Library() 7 7 8 def build_cache_key(*fragments): 9 """ 10 Generates an unique key for every unique set of arguments 11 """ 12 key = u":".join(fragments) 13 return key.replace("%", "%25").replace(" ", "%20") 14 8 15 class CacheNode(Node): 9 16 def __init__(self, nodelist, expire_time_var, fragment_name, vary_on): 10 17 self.nodelist = nodelist … … 22 29 except (ValueError, TypeError): 23 30 raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time) 24 31 # Build a unicode key for this fragment and all vary-on's. 25 cache_key = u':'.join([self.fragment_name] +[force_unicode(resolve_variable(var, context)) for var in self.vary_on])32 cache_key = build_cache_key(self.fragment_name, *[force_unicode(resolve_variable(var, context)) for var in self.vary_on]) 26 33 value = cache.get(cache_key) 27 34 if value is None: 28 35 value = self.nodelist.render(context)