Permalink
Browse files

Deprecated django.utils.importlib

This was a shim for pre-Python 2.7 support.
  • Loading branch information...
1 parent ac09558 commit fdd7a355bf053217d25b8d2189e37069c1304283 @claudep claudep committed Jul 29, 2013
Showing with 64 additions and 49 deletions.
  1. +1 −1 django/conf/__init__.py
  2. +2 −1 django/conf/urls/__init__.py
  3. +1 −1 django/contrib/admin/__init__.py
  4. +1 −1 django/contrib/admindocs/views.py
  5. +1 −1 django/contrib/auth/hashers.py
  6. +1 −1 django/contrib/comments/__init__.py
  7. +1 −1 django/contrib/formtools/tests/wizard/storage.py
  8. +2 −1 django/contrib/formtools/tests/wizard/test_forms.py
  9. +3 −2 django/contrib/gis/geometry/backend/__init__.py
  10. +2 −1 django/contrib/sessions/management/commands/clearsessions.py
  11. +1 −1 django/contrib/sessions/middleware.py
  12. +1 −1 django/contrib/staticfiles/storage.py
  13. +1 −1 django/core/cache/__init__.py
  14. +3 −3 django/core/management/__init__.py
  15. +1 −1 django/core/management/commands/flush.py
  16. +2 −1 django/core/management/commands/startapp.py
  17. +2 −1 django/core/management/commands/startproject.py
  18. +1 −1 django/core/management/commands/syncdb.py
  19. +2 −1 django/core/serializers/__init__.py
  20. +1 −1 django/core/servers/fastcgi.py
  21. +1 −1 django/core/urlresolvers.py
  22. +1 −1 django/db/backends/__init__.py
  23. +6 −6 django/db/models/loading.py
  24. +2 −2 django/db/utils.py
  25. +1 −1 django/template/base.py
  26. +1 −1 django/template/loaders/app_directories.py
  27. +1 −1 django/test/client.py
  28. +1 −1 django/test/simple.py
  29. +2 −2 django/utils/formats.py
  30. +5 −0 django/utils/importlib.py
  31. +1 −1 django/utils/module_loading.py
  32. +1 −1 django/utils/translation/trans_real.py
  33. +1 −1 django/views/i18n.py
  34. +2 −0 docs/internals/deprecation.txt
  35. +5 −4 docs/releases/1.7.txt
  36. +1 −1 tests/i18n/tests.py
  37. +1 −1 tests/test_runner/tests.py
  38. +1 −1 tests/utils_tests/test_module_loading.py
@@ -6,6 +6,7 @@
a list of all possible variables.
"""
+import importlib
import logging
import os
import sys
@@ -15,7 +16,6 @@
from django.conf import global_settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import LazyObject, empty
-from django.utils import importlib
from django.utils.module_loading import import_by_path
from django.utils import six
@@ -1,7 +1,8 @@
+from importlib import import_module
+
from django.core.urlresolvers import (RegexURLPattern,
RegexURLResolver, LocaleRegexURLResolver)
from django.core.exceptions import ImproperlyConfigured
-from django.utils.importlib import import_module
from django.utils import six
@@ -17,8 +17,8 @@ def autodiscover():
"""
import copy
+ from importlib import import_module
from django.conf import settings
- from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
for app in settings.INSTALLED_APPS:
@@ -1,3 +1,4 @@
+from importlib import import_module
import inspect
import os
import re
@@ -13,7 +14,6 @@
from django.core import urlresolvers
from django.contrib.admindocs import utils
from django.contrib.sites.models import Site
-from django.utils.importlib import import_module
from django.utils._os import upath
from django.utils import six
from django.utils.translation import ugettext as _
@@ -3,11 +3,11 @@
import base64
import binascii
import hashlib
+import importlib
from django.dispatch import receiver
from django.conf import settings
from django.test.signals import setting_changed
-from django.utils import importlib
from django.utils.datastructures import SortedDict
from django.utils.encoding import force_bytes, force_str, force_text
from django.core.exceptions import ImproperlyConfigured
@@ -1,10 +1,10 @@
+from importlib import import_module
import warnings
from django.conf import settings
from django.core import urlresolvers
from django.core.exceptions import ImproperlyConfigured
from django.contrib.comments.models import Comment
from django.contrib.comments.forms import CommentForm
-from django.utils.importlib import import_module
warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning)
@@ -1,8 +1,8 @@
from datetime import datetime
+from importlib import import_module
from django.http import HttpRequest
from django.conf import settings
-from django.utils.importlib import import_module
from django.contrib.auth.models import User
@@ -1,11 +1,12 @@
from __future__ import unicode_literals
+from importlib import import_module
+
from django import forms, http
from django.conf import settings
from django.db import models
from django.test import TestCase
from django.template.response import TemplateResponse
-from django.utils.importlib import import_module
from django.contrib.auth.models import User
@@ -1,11 +1,12 @@
+from importlib import import_module
+
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
-from django.utils.importlib import import_module
geom_backend = getattr(settings, 'GEOMETRY_BACKEND', 'geos')
try:
- module = import_module('.%s' % geom_backend, 'django.contrib.gis.geometry.backend')
+ module = import_module('django.contrib.gis.geometry.backend.%s' % geom_backend)
except ImportError:
try:
module = import_module(geom_backend)
@@ -1,6 +1,7 @@
+from importlib import import_module
+
from django.conf import settings
from django.core.management.base import NoArgsCommand
-from django.utils.importlib import import_module
class Command(NoArgsCommand):
@@ -1,9 +1,9 @@
+from importlib import import_module
import time
from django.conf import settings
from django.utils.cache import patch_vary_headers
from django.utils.http import cookie_date
-from django.utils.importlib import import_module
class SessionMiddleware(object):
def __init__(self):
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
import hashlib
+from importlib import import_module
import os
import posixpath
import re
@@ -18,7 +19,6 @@
from django.utils.datastructures import SortedDict
from django.utils.encoding import force_bytes, force_text
from django.utils.functional import LazyObject
-from django.utils.importlib import import_module
from django.utils._os import upath
from django.contrib.staticfiles.utils import check_settings, matches_patterns
@@ -14,6 +14,7 @@
See docs/topics/cache.txt for information on the public API.
"""
+import importlib
try:
from urllib.parse import parse_qsl
except ImportError: # Python 2
@@ -24,7 +25,6 @@
from django.core.cache.backends.base import (
InvalidCacheBackendError, CacheKeyWarning, BaseCache)
from django.core.exceptions import ImproperlyConfigured
-from django.utils import importlib
from django.utils.module_loading import import_by_path
@@ -1,13 +1,13 @@
import collections
+import imp
+from importlib import import_module
+from optparse import OptionParser, NO_DEFAULT
import os
import sys
-from optparse import OptionParser, NO_DEFAULT
-import imp
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError, handle_default_options
from django.core.management.color import color_style
-from django.utils.importlib import import_module
from django.utils import six
# For backwards compatibility: get_version() used to be in this module.
@@ -1,4 +1,5 @@
import sys
+from importlib import import_module
from optparse import make_option
from django.conf import settings
@@ -7,7 +8,6 @@
from django.core.management.base import NoArgsCommand, CommandError
from django.core.management.color import no_style
from django.core.management.sql import sql_flush, emit_post_sync_signal
-from django.utils.importlib import import_module
from django.utils.six.moves import input
from django.utils import six
@@ -1,6 +1,7 @@
+from importlib import import_module
+
from django.core.management.base import CommandError
from django.core.management.templates import TemplateCommand
-from django.utils.importlib import import_module
class Command(TemplateCommand):
@@ -1,7 +1,8 @@
+from importlib import import_module
+
from django.core.management.base import CommandError
from django.core.management.templates import TemplateCommand
from django.utils.crypto import get_random_string
-from django.utils.importlib import import_module
class Command(TemplateCommand):
@@ -1,3 +1,4 @@
+from importlib import import_module
from optparse import make_option
import itertools
import traceback
@@ -9,7 +10,6 @@
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal, emit_pre_sync_signal
from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
from django.utils.datastructures import SortedDict
-from django.utils.importlib import import_module
class Command(NoArgsCommand):
@@ -16,8 +16,9 @@
"""
+import importlib
+
from django.conf import settings
-from django.utils import importlib
from django.utils import six
from django.core.serializers.base import SerializerDoesNotExist
@@ -12,9 +12,9 @@
pass to this server.
"""
+import importlib
import os
import sys
-from django.utils import importlib
__version__ = "0.1"
__all__ = ["runfastcgi"]
@@ -8,6 +8,7 @@
"""
from __future__ import unicode_literals
+from importlib import import_module
import re
from threading import local
@@ -17,7 +18,6 @@
from django.utils.encoding import force_str, force_text, iri_to_uri
from django.utils.functional import memoize, lazy
from django.utils.http import urlquote
-from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
from django.utils.regex_helper import normalize
from django.utils import six
@@ -9,6 +9,7 @@
from django.utils.six.moves import _dummy_thread as thread
from collections import namedtuple
from contextlib import contextmanager
+from importlib import import_module
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS
@@ -17,7 +18,6 @@
from django.db.transaction import TransactionManagementError
from django.db.utils import DatabaseErrorWrapper
from django.utils.functional import cached_property
-from django.utils.importlib import import_module
from django.utils import six
from django.utils import timezone
@@ -1,17 +1,17 @@
"Utilities for loading models and the modules that contain them."
+import imp
+from importlib import import_module
+import os
+import sys
+
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.datastructures import SortedDict
-from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
from django.utils._os import upath
from django.utils import six
-import imp
-import sys
-import os
-
__all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models',
'load_app', 'app_cache_ready')
@@ -100,7 +100,7 @@ def load_app(self, app_name, can_postpone=False):
self.nesting_level += 1
app_module = import_module(app_name)
try:
- models = import_module('.' + MODELS_MODULE_NAME, app_name)
+ models = import_module('%s.%s' % (app_name, MODELS_MODULE_NAME))
except ImportError:
self.nesting_level -= 1
# If the app doesn't have a models module, we can just ignore the
View
@@ -1,4 +1,5 @@
from functools import wraps
+from importlib import import_module
import os
import pkgutil
from threading import local
@@ -7,7 +8,6 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property
-from django.utils.importlib import import_module
from django.utils.module_loading import import_by_path
from django.utils._os import upath
from django.utils import six
@@ -104,7 +104,7 @@ def inner(*args, **kwargs):
def load_backend(backend_name):
# Look for a fully qualified database backend name
try:
- return import_module('.base', backend_name)
+ return import_module('%s.base' % backend_name)
except ImportError as e_user:
# The database backend wasn't found. Display a helpful error message
# listing all possible (built-in) database backends.
@@ -2,12 +2,12 @@
import re
from functools import partial
+from importlib import import_module
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.text import (smart_split, unescape_string_literal,
get_text_list)
@@ -3,6 +3,7 @@
packages.
"""
+from importlib import import_module
import os
import sys
@@ -11,7 +12,6 @@
from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader
from django.utils._os import safe_join
-from django.utils.importlib import import_module
from django.utils import six
# At compile time, cache the directories to search.
@@ -5,6 +5,7 @@
import re
import mimetypes
from copy import copy
+from importlib import import_module
from io import BytesIO
try:
from urllib.parse import unquote, urlparse, urlsplit
@@ -25,7 +26,6 @@
from django.utils.functional import curry
from django.utils.encoding import force_bytes, force_str
from django.utils.http import urlencode
-from django.utils.importlib import import_module
from django.utils.itercompat import is_iterable
from django.utils import six
from django.test.utils import ContextList
@@ -3,6 +3,7 @@
version 1.8.
"""
+from importlib import import_module
import json
import re
import unittest as real_unittest
@@ -15,7 +16,6 @@
# django.utils.unittest is deprecated, but so is django.test.simple,
# and the latter will be removed before the former.
from django.utils import unittest
-from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
__all__ = ('DjangoTestSuiteRunner',)
Oops, something went wrong.

0 comments on commit fdd7a35

Please sign in to comment.