From c485e236bd7e5ea40c64b2fe54d85dbb15b2fd39 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 18 Mar 2009 16:55:59 +0000 Subject: Fixed #8193: all dynamic imports in Django are now done correctly. I know this because Brett Cannon borrowed the time machine and brought Python 2.7's '`importlib` back for inclusion in Django. Thanks for the patch-from-the-future, Brett! git-svn-id: http://code.djangoproject.com/svn/django/trunk@10088 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/template/loaders/app_directories.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'django/template/loaders') 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') -- cgit v1.3