#8116: django.template.loader.select_template should not silently skip a template which includes another template that does not exist ---------------------------------------------+------------------------------ Reporter: Michael P. Jung | Owner: nobody Status: new | Milestone: post-1.0 Component: Template system | Version: SVN Resolution: | Keywords: Stage: Design decision needed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------+------------------------------ Comment (by Mike Amy):
Ran into this one... Problem is bad exception handling... TemplateDoesNotExist exceptions arising from the missing child templates are ignored in select_template, in effect causing it to ignore the parent template. A fix is to check the message in the exception (in django/template/loader.py ): {{{ def select_template(template_name_list): "Given a list of template names, returns the first that can be loaded." for template_name in template_name_list: try: return get_template(template_name) except TemplateDoesNotExist, e: if e.message is template_name: # <<< Check the template is not a child template continue raise # If we get here, none of the templates could be loaded raise TemplateDoesNotExist, template_name_list }}} However, that is making assumptions about the exception, there ought to be a better way, like a template_name attribute in the exception -- Ticket URL: <http://code.djangoproject.com/ticket/8116#comment:3> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---