Django

Code

Changeset 8533

Show
Ignore:
Timestamp:
08/24/08 23:52:55 (3 months ago)
Author:
mtredinnick
Message:

Fixed #7460 -- Made the "cache" template tag always generate keys that can be
used with the memcache backend (which has the strongest restriction on keys).
Based on a patch from trbs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/templatetags/cache.py

    r7754 r8533  
    33from django.core.cache import cache 
    44from django.utils.encoding import force_unicode 
     5from django.utils.http import urlquote 
    56 
    67register = Library() 
     
    2324            raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time) 
    2425        # 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]) 
     26        cache_key = u':'.join([self.fragment_name] + [urlquote(resolve_variable(var, context)) for var in self.vary_on]) 
    2627        value = cache.get(cache_key) 
    2728        if value is None: 
  • django/trunk/tests/regressiontests/templates/tests.py

    r8393 r8533  
    918918            'cache15': ('{% load cache %}{% cache foo bar %}{% endcache %}', {'foo': []}, template.TemplateSyntaxError), 
    919919 
     920            # Regression test for #7460. 
     921            'cache16': ('{% load cache %}{% cache 1 foo bar %}{% endcache %}', {'foo': 'foo', 'bar': 'with spaces'}, ''), 
     922 
    920923            ### AUTOESCAPE TAG ############################################## 
    921924            'autoescape-tag01': ("{% autoescape off %}hello{% endautoescape %}", {}, "hello"),