Ticket #9874: template_cache.diff
File template_cache.diff, 2.0 KB (added by , 16 years ago) |
---|
-
django1.02/django/template/loader_tags.py
61 61 if hasattr(parent, 'render'): 62 62 return parent # parent is a Template object 63 63 try: 64 source, origin = find_template_source(parent, self.template_dirs)64 return get_template(parent) 65 65 except TemplateDoesNotExist: 66 raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent 67 else: 68 return get_template_from_string(source, origin, parent) 66 raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent 69 67 70 68 def render(self, context): 71 69 compiled_parent = self.get_parent(context) -
django1.02/django/template/loader.py
25 25 from django.conf import settings 26 26 27 27 template_source_loaders = None 28 template_cache = {} 28 29 29 30 class LoaderOrigin(Origin): 30 31 def __init__(self, display_name, loader, name, dirs): … … 77 78 Returns a compiled Template object for the given template name, 78 79 handling template inheritance recursively. 79 80 """ 80 source, origin = find_template_source(template_name) 81 template = get_template_from_string(source, origin, template_name) 81 global template_cache 82 if template_name in template_cache: 83 template = template_cache[template_name] 84 else: 85 source, origin = find_template_source(template_name) 86 template = get_template_from_string(source, origin, template_name) 87 template_cache[template_name] = template 82 88 return template 83 89 84 90 def get_template_from_string(source, origin=None, name=None):