summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
Diffstat (limited to 'django/template')
-rw-r--r--django/template/__init__.py3
-rw-r--r--django/template/context.py5
-rw-r--r--django/template/loader.py3
-rw-r--r--django/template/loaders/app_directories.py11
4 files changed, 9 insertions, 13 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index bdc4b890d1..d008b7f874 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -52,6 +52,7 @@ import re
from inspect import getargspec
from django.conf import settings
from django.template.context import Context, RequestContext, ContextPopException
+from django.utils.importlib import import_module
from django.utils.itercompat import is_iterable
from django.utils.functional import curry, Promise
from django.utils.text import smart_split
@@ -935,7 +936,7 @@ def get_library(module_name):
lib = libraries.get(module_name, None)
if not lib:
try:
- mod = __import__(module_name, {}, {}, [''])
+ mod = import_module(module_name)
except ImportError, e:
raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e))
try:
diff --git a/django/template/context.py b/django/template/context.py
index 8f16a95021..1f136595e1 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -1,5 +1,6 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
+from django.utils.importlib import import_module
_standard_context_processors = None
@@ -62,7 +63,7 @@ class Context(object):
def update(self, other_dict):
"Like dict.update(). Pushes an entire dictionary's keys and values onto the context."
- if not hasattr(other_dict, '__getitem__'):
+ if not hasattr(other_dict, '__getitem__'):
raise TypeError('other_dict must be a mapping (dictionary-like) object.')
self.dicts = [other_dict] + self.dicts
return other_dict
@@ -77,7 +78,7 @@ def get_standard_processors():
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
try:
- mod = __import__(module, {}, {}, [attr])
+ mod = import_module(module)
except ImportError, e:
raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))
try:
diff --git a/django/template/loader.py b/django/template/loader.py
index 1d7d945ef7..8195c4b798 100644
--- a/django/template/loader.py
+++ b/django/template/loader.py
@@ -22,6 +22,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.template import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins
+from django.utils.importlib import import_module
from django.conf import settings
template_source_loaders = None
@@ -51,7 +52,7 @@ def find_template_source(name, dirs=None):
i = path.rfind('.')
module, attr = path[:i], path[i+1:]
try:
- mod = __import__(module, globals(), locals(), [attr])
+ mod = import_module(module)
except ImportError, e:
raise ImproperlyConfigured, 'Error importing template source loader %s: "%s"' % (module, e)
try:
diff --git a/django/template/loaders/app_directories.py b/django/template/loaders/app_directories.py
index 975b8ad95f..b5ae602666 100644
--- a/django/template/loaders/app_directories.py
+++ b/django/template/loaders/app_directories.py
@@ -10,21 +10,14 @@ from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.template import TemplateDoesNotExist
from django.utils._os import safe_join
+from django.utils.importlib import import_module
# At compile time, cache the directories to search.
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
app_template_dirs = []
for app in settings.INSTALLED_APPS:
- i = app.rfind('.')
- if i == -1:
- m, a = app, None
- else:
- m, a = app[:i], app[i+1:]
try:
- if a is None:
- mod = __import__(m, {}, {}, [])
- else:
- mod = getattr(__import__(m, {}, {}, [a]), a)
+ mod = import_module(app)
except ImportError, e:
raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0])
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')