Ticket #18260: cachetag.3.diff

File cachetag.3.diff, 2.1 KB (added by FunkyBob, 3 years ago)

Fixed error message

  • django/templatetags/cache.py

    diff --git a/django/templatetags/cache.py b/django/templatetags/cache.py
    index 8183452..afe0363 100644
    a b register = Library() 
    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
    class CacheNode(Node): 
    1717        try:
    1818            expire_time = self.expire_time_var.resolve(context)
    1919        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)
    2121        try:
    2222            expire_time = int(expire_time)
    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)
    def do_cache(parser, token): 
    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.split_contents()]
    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