diff --git a/django/templatetags/cache.py b/django/templatetags/cache.py
index 8183452..afe0363 100644
a
|
b
|
register = Library()
|
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 | |
… |
… |
class CacheNode(Node):
|
17 | 17 | try: |
18 | 18 | expire_time = self.expire_time_var.resolve(context) |
19 | 19 | except VariableDoesNotExist: |
20 | | raise TemplateSyntaxError('"cache" tag got an unknown variable: %r' % self.expire_time_var.var) |
| 20 | raise TemplateSyntaxError('"cache" tag got an unknown variable: %r' % self.expire_time_var.token) |
21 | 21 | try: |
22 | 22 | expire_time = int(expire_time) |
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) |
… |
… |
def do_cache(parser, token):
|
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.split_contents()] |
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:]) |