Ticket #1675: ticket_1675.diff
File ticket_1675.diff, 2.4 KB (added by , 19 years ago) |
---|
-
django/template/__init__.py
861 861 try: 862 862 mod = __import__(module_name, '', '', ['']) 863 863 except ImportError, e: 864 raise I nvalidTemplateLibrary, "Could not load template library from %s, %s" % (module_name, e)864 raise ImportError, "Could not load template library from %s, %s" % (module_name, e) 865 865 try: 866 866 lib = mod.register 867 867 libraries[module_name] = lib … … 869 869 raise InvalidTemplateLibrary, "Template library %s does not have a variable named 'register'" % module_name 870 870 return lib 871 871 872 templatetag_searchpath = [ "django" ] 873 templatetag_searchpath.extend( settings.INSTALLED_APPS ) 874 872 875 def add_to_builtins(module_name): 873 876 builtins.append(get_library(module_name)) 874 877 875 878 add_to_builtins('django.template.defaulttags') 876 879 add_to_builtins('django.template.defaultfilters') 880 881 882 -
django/template/defaulttags.py
3 3 from django.template import Node, NodeList, Template, Context, resolve_variable 4 4 from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END 5 5 from django.template import get_library, Library, InvalidTemplateLibrary 6 from django.template import templatetag_searchpath 6 7 from django.conf import settings 7 8 import sys 8 9 … … 645 646 bits = token.contents.split() 646 647 for taglib in bits[1:]: 647 648 # add the library to the parser 648 try: 649 lib = get_library("django.templatetags.%s" % taglib.split('.')[-1]) 649 650 lib = None 651 for app in templatetag_searchpath: 652 try: 653 lib = get_library("%s.templatetags.%s" % (app,taglib)) 654 except ImportError,e: 655 continue 650 656 parser.add_library(lib) 651 except InvalidTemplateLibrary, e: 652 raise TemplateSyntaxError, "'%s' is not a valid tag library: %s" % (taglib, e) 657 break 658 if not lib: 659 raise InvalidTemplateLibrary, "'%s' is not a valid tag library" % (taglib,) 653 660 return LoadNode() 654 661 load = register.tag(load) 655 662