mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Changed template library system so that it looks for a module-level variable named 'register' rather than the first instance of template.Library it finds
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1461 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -890,13 +890,11 @@ def get_library(module_name):
|
||||
mod = __import__(module_name, '', '', [''])
|
||||
except ImportError, e:
|
||||
raise InvalidTemplateLibrary, "Could not load template library from %s, %s" % (module_name, e)
|
||||
for k, v in mod.__dict__.items():
|
||||
if isinstance(v, Library):
|
||||
lib = v
|
||||
libraries[module_name] = lib
|
||||
break
|
||||
if not lib:
|
||||
raise InvalidTemplateLibrary, "Template library %s does not have a Library member" % module_name
|
||||
try:
|
||||
lib = mod.register
|
||||
libraries[module_name] = lib
|
||||
except AttributeError:
|
||||
raise InvalidTemplateLibrary, "Template library %s does not have a variable named 'register'" % module_name
|
||||
return lib
|
||||
|
||||
def add_to_builtins(module_name):
|
||||
|
||||
Reference in New Issue
Block a user