summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-27 16:43:56 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-27 16:43:56 +0000
commit2fb95f1de699fbc3c39ac83dbf5fabb63af96642 (patch)
tree36dbf962d03912b2620d5a5ad3b4e4d1eb83b703 /django
parent2564f34c2b0a9ef70bf7079ff157a6d2c90fe3d8 (diff)
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
Diffstat (limited to 'django')
-rw-r--r--django/core/template/__init__.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/django/core/template/__init__.py b/django/core/template/__init__.py
index 8144e651a1..c399c93c14 100644
--- a/django/core/template/__init__.py
+++ b/django/core/template/__init__.py
@@ -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):