27 | | template_source_loaders = [] |
28 | | for path in TEMPLATE_LOADERS: |
29 | | i = path.rfind('.') |
30 | | module, attr = path[:i], path[i+1:] |
31 | | try: |
32 | | mod = __import__(module, globals(), locals(), [attr]) |
33 | | except ImportError, e: |
34 | | raise ImproperlyConfigured, 'Error importing template source loader %s: "%s"' % (module, e) |
35 | | try: |
36 | | func = getattr(mod, attr) |
37 | | except AttributeError: |
38 | | raise ImproperlyConfigured, 'Module "%s" does not define a "%s" callable template source loader' % (module, attr) |
39 | | if not func.is_usable: |
40 | | import warnings |
41 | | warnings.warn("Your TEMPLATE_LOADERS setting includes %r, but your Python installation doesn't support that type of template loading. Consider removing that line from TEMPLATE_LOADERS." % path) |
42 | | else: |
43 | | template_source_loaders.append(func) |
44 | | |
| 42 | global template_source_loaders |
| 43 | if not 'template_source_loaders' in globals(): |
| 44 | template_source_loaders = [] |
| 45 | for path in TEMPLATE_LOADERS: |
| 46 | i = path.rfind('.') |
| 47 | module, attr = path[:i], path[i+1:] |
| 48 | try: |
| 49 | mod = __import__(module, globals(), locals(), [attr]) |
| 50 | except ImportError, e: |
| 51 | raise ImproperlyConfigured, 'Error importing template source loader %s: "%s"' % (module, e) |
| 52 | try: |
| 53 | func = getattr(mod, attr) |
| 54 | except AttributeError: |
| 55 | raise ImproperlyConfigured, 'Module "%s" does not define a "%s" callable template source loader' % (module, attr) |
| 56 | if not func.is_usable: |
| 57 | import warnings |
| 58 | warnings.warn("Your TEMPLATE_LOADERS setting includes %r, but your Python installation doesn't support that type of template loading. Consider removing that line from TEMPLATE_LOADERS." % path) |
| 59 | else: |
| 60 | template_source_loaders.append(func) |