Curtis Maloney
unread,Jul 7, 2016, 11:01:09 PM7/7/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-d...@googlegroups.com
Hey,
a client of mine was having a strange bug with the caching template
loader, which we've yet to identify, but as I was looking at the code, I
saw the following:
def load_template(self, template_name, template_dirs=None):
key = self.cache_key(template_name, template_dirs)
template_tuple = self.template_cache.get(key)
# A cached previous failure:
if template_tuple is TemplateDoesNotExist:
raise TemplateDoesNotExist
elif template_tuple is None:
template, origin = self.find_template(template_name,
template_dirs)
if not hasattr(template, 'render'):
try:
template = Template(template, origin,
template_name, self.engine)
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)
# of the actual template that does not exist.
self.template_cache[key] = (template, origin)
self.template_cache[key] = (template, None)
return self.template_cache[key]
Now... in that "except" clause at the end, it updates the cache dict
with (template, origin).. only then to fall through to set it AGAIN
_immediately_.... with (template, None)
Surely this is wrong one way or the other?
--
Curtis