Re: Problem with caching template loader

2016-07-07 Thread Preston Timmons
Yep, that looks wrong. Looks like it was added in this commit:

https://github.com/django/django/commit/f33db5a09acfc3df3085235a5712c46094eb9a0d

The test case could be improved also by checking the appropriate key is set.

Preston

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/de745f58-3ad6-4688-881f-1379a0e9a4ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with caching template loader

2016-07-07 Thread Curtis Maloney

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

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/b5d6fdd0-303a-68b0-c0c3-41732683910b%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.