Ticket #5557: django-utils-cache-py.patch

File django-utils-cache-py.patch, 1.8 KB (added by eriks@…, 17 years ago)

Proposed patch

  • cache.py

     
    2323from email.Utils import formatdate
    2424from django.conf import settings
    2525from django.core.cache import cache
    26 from django.utils.encoding import smart_str
     26from django.utils.encoding import smart_str, iri_to_uri
    2727
    2828cc_delim_re = re.compile(r'\s*,\s*')
    2929
     
    118118        value = request.META.get(header, None)
    119119        if value is not None:
    120120            ctx.update(value)
    121     return 'views.decorators.cache.cache_page.%s.%s.%s' % (key_prefix, request.path, ctx.hexdigest())
     121    return 'views.decorators.cache.cache_page.%s.%s.%s' % (key_prefix, iri_to_uri(request.path), ctx.hexdigest())
    122122
    123123def get_cache_key(request, key_prefix=None):
    124124    """
     
    132132    """
    133133    if key_prefix is None:
    134134        key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
    135     cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path)
     135    cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, iri_to_uri(request.path))
    136136    headerlist = cache.get(cache_key, None)
    137137    if headerlist is not None:
    138138        return _generate_cache_key(request, headerlist, key_prefix)
     
    156156        key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
    157157    if cache_timeout is None:
    158158        cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
    159     cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, request.path)
     159    cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, iri_to_uri(request.path))
    160160    if response.has_header('Vary'):
    161161        headerlist = ['HTTP_'+header.upper().replace('-', '_') for header in vary_delim_re.split(response['Vary'])]
    162162        cache.set(cache_key, headerlist, cache_timeout)
Back to Top