diff options
author | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-21 14:25:26 +0000 |
---|---|---|
committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-21 14:25:26 +0000 |
commit | 84060a1f7aff712f6fde71884c501b50c9ef3d46 (patch) | |
tree | 68880beb61fc0ee84cefa5aa19b91a5d989e7168 /django | |
parent | 5acd9cd8bab0866120d089e5e3d563e23fa3fd9e (diff) | |
download | django-84060a1f7aff712f6fde71884c501b50c9ef3d46.tar.gz |
Refs #13573 -- Modified the key technique added in r13295 to be more robust against potential key collisions while keeping key names human-readable. Thanks to Alex for being finicky.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13299 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r-- | django/template/loaders/cached.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py index 7d4e1ef0c2..9a56b5ebd3 100644 --- a/django/template/loaders/cached.py +++ b/django/template/loaders/cached.py @@ -3,10 +3,11 @@ Wrapper class that takes a list of template loaders as an argument and attempts to load templates from them in order, caching the result. """ +from django.core.exceptions import ImproperlyConfigured from django.template import TemplateDoesNotExist from django.template.loader import BaseLoader, get_template_from_string, find_template_loader, make_origin +from django.utils.hashcompat import sha_constructor from django.utils.importlib import import_module -from django.core.exceptions import ImproperlyConfigured class Loader(BaseLoader): is_usable = True @@ -34,8 +35,10 @@ class Loader(BaseLoader): raise TemplateDoesNotExist(name) def load_template(self, template_name, template_dirs=None): - # Use hash(..) to avoid saving potentially large template_dirs values - key = hash((template_name, template_dirs)) + key = template_name + if template_dirs: + # If template directories were specified, use a hash to differentiate + key = '-'.join([template_name, sha_constructor('|'.join(template_dirs)).hexdigest()]) if key not in self.template_cache: template, origin = self.find_template(template_name, template_dirs) |