Ticket #18260: cachetag.diff

File cachetag.diff, 1.6 KB (added by anonymous, 3 years ago)
  • django/templatetags/cache.py

    old new  
    99class CacheNode(Node):
    1010    def __init__(self, nodelist, expire_time_var, fragment_name, vary_on):
    1111        self.nodelist = nodelist
    12         self.expire_time_var = Variable(expire_time_var)
     12        self.expire_time_var = expire_time_var
    1313        self.fragment_name = fragment_name
    1414        self.vary_on = vary_on
    1515
     
    2323        except (ValueError, TypeError):
    2424            raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time)
    2525        # 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())
    2828        value = cache.get(cache_key)
    2929        if value is None:
    3030            value = self.nodelist.render(context)
     
    5555    """
    5656    nodelist = parser.parse(('endcache',))
    5757    parser.delete_first_token()
    58     tokens = token.contents.split()
     58    tokens = [parser.compile_filter(token) for token in token.contents.split()]
    5959    if len(tokens) < 3:
    6060        raise TemplateSyntaxError(u"'%r' tag requires at least 2 arguments." % tokens[0])
    6161    return CacheNode(nodelist, tokens[1], tokens[2], tokens[3:])
Back to Top