summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-05-21 08:54:15 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-05-21 08:54:15 +0000
commit8a6cb3d969b6fd18abb952b8d0e5ccd10488a742 (patch)
tree01c5717e88a958ebc52f043481bdebf50a5fd67c /django
parent6b2fd346ad10a2b2682881e249e8e1e79cafc1a8 (diff)
Fixed #13573 -- Corrected problem with template caching when template directories are provided. Thanks to lamby for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13295 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/template/loaders/cached.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
index 788dad90bc..7d4e1ef0c2 100644
--- a/django/template/loaders/cached.py
+++ b/django/template/loaders/cached.py
@@ -34,19 +34,22 @@ class Loader(BaseLoader):
raise TemplateDoesNotExist(name)
def load_template(self, template_name, template_dirs=None):
- if template_name not in self.template_cache:
+ # Use hash(..) to avoid saving potentially large template_dirs values
+ key = hash((template_name, template_dirs))
+
+ if key not in self.template_cache:
template, origin = self.find_template(template_name, template_dirs)
if not hasattr(template, 'render'):
try:
template = get_template_from_string(template, origin, template_name)
except TemplateDoesNotExist:
- # If compiling the template we found raises TemplateDoesNotExist,
- # back off to returning the source and display name for the template
- # we were asked to load. This allows for correct identification (later)
+ # If compiling the template we found raises TemplateDoesNotExist,
+ # back off to returning the source and display name for the template
+ # we were asked to load. This allows for correct identification (later)
# of the actual template that does not exist.
return template, origin
- self.template_cache[template_name] = template
- return self.template_cache[template_name], None
+ self.template_cache[key] = template
+ return self.template_cache[key], None
def reset(self):
"Empty the template cache."