Ticket #13573: 36-include-template_dirs-in-template-caching-hash.diff

File 36-include-template_dirs-in-template-caching-hash.diff, 1.2 KB (added by Chris Lamb, 14 years ago)
  • django/template/loaders/cached.py

    diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
    index 788dad9..991580e 100644
    a b class Loader(BaseLoader):  
    3434        raise TemplateDoesNotExist(name)
    3535
    3636    def load_template(self, template_name, template_dirs=None):
    37         if template_name not in self.template_cache:
     37        # Use hash(..) to avoid saving potentially large template_dirs values
     38        key = hash((template_name, template_dirs))
     39
     40        if key not in self.template_cache:
    3841            template, origin = self.find_template(template_name, template_dirs)
    3942            if not hasattr(template, 'render'):
    4043                try:
    class Loader(BaseLoader):  
    4548                    # we were asked to load. This allows for correct identification (later)
    4649                    # of the actual template that does not exist.
    4750                    return template, origin
    48             self.template_cache[template_name] = template
    49         return self.template_cache[template_name], None
     51            self.template_cache[key] = template
     52        return self.template_cache[key], None
    5053
    5154    def reset(self):
    5255        "Empty the template cache."
Back to Top