diff -rupN django/templatetags/cache.py django-my/templatetags/cache.py
old
|
new
|
from django.template import resolve_vari
|
3 | 3 | from django.core.cache import cache |
4 | 4 | from django.utils.encoding import force_unicode |
5 | 5 | from django.utils.http import urlquote |
| 6 | from django.utils.hashcompat import md5_constructor |
6 | 7 | |
7 | 8 | register = Library() |
8 | 9 | |
… |
… |
class CacheNode(Node):
|
23 | 24 | except (ValueError, TypeError): |
24 | 25 | raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time) |
25 | 26 | # Build a unicode key for this fragment and all vary-on's. |
26 | | cache_key = u':'.join([self.fragment_name] + [urlquote(resolve_variable(var, context)) for var in self.vary_on]) |
| 27 | cache_key = md5_constructor() |
| 28 | cache_key.update(u':'.join([self.fragment_name] + [urlquote(resolve_variable(var, context)) for var in self.vary_on])) |
| 29 | cache_key = cache_key.hexdigest() |
27 | 30 | value = cache.get(cache_key) |
28 | 31 | if value is None: |
29 | 32 | value = self.nodelist.render(context) |