summaryrefslogtreecommitdiff
path: root/django/core/cache
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2014-01-20 22:15:14 +0200
committerTim Graham <timograham@gmail.com>2014-02-08 11:12:19 -0500
commit5d263dee304fdaf95e18d2f0619d6925984a7f02 (patch)
tree764bc0cd21bca796d9f1bd0b8d2645a9773e48de /django/core/cache
parentfcc21837dc691ba6465853c0b68927cb075a4591 (diff)
Fixed #21674 -- Deprecated the import_by_path() function in favor of import_string().
Thanks Aymeric Augustin for the suggestion and review.
Diffstat (limited to 'django/core/cache')
-rw-r--r--django/core/cache/__init__.py10
-rw-r--r--django/core/cache/backends/base.py4
2 files changed, 7 insertions, 7 deletions
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
index c362800dcc..603086a39c 100644
--- a/django/core/cache/__init__.py
+++ b/django/core/cache/__init__.py
@@ -20,7 +20,7 @@ from django.core import signals
from django.core.cache.backends.base import (
InvalidCacheBackendError, CacheKeyWarning, BaseCache)
from django.core.exceptions import ImproperlyConfigured
-from django.utils.module_loading import import_by_path
+from django.utils.module_loading import import_string
__all__ = [
@@ -69,8 +69,8 @@ def _create_cache(backend, **kwargs):
except KeyError:
try:
# Trying to import the given backend, in case it's a dotted path
- import_by_path(backend)
- except ImproperlyConfigured as e:
+ import_string(backend)
+ except ImportError as e:
raise InvalidCacheBackendError("Could not find backend '%s': %s" % (
backend, e))
location = kwargs.pop('LOCATION', '')
@@ -80,8 +80,8 @@ def _create_cache(backend, **kwargs):
params.update(kwargs)
backend = params.pop('BACKEND')
location = params.pop('LOCATION', '')
- backend_cls = import_by_path(backend)
- except (AttributeError, ImportError, ImproperlyConfigured) as e:
+ backend_cls = import_string(backend)
+ except ImportError as e:
raise InvalidCacheBackendError(
"Could not find backend '%s': %s" % (backend, e))
return backend_cls(location, params)
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py
index 2c3151369a..ae83865db8 100644
--- a/django/core/cache/backends/base.py
+++ b/django/core/cache/backends/base.py
@@ -5,7 +5,7 @@ import time
import warnings
from django.core.exceptions import ImproperlyConfigured, DjangoRuntimeWarning
-from django.utils.module_loading import import_by_path
+from django.utils.module_loading import import_string
class InvalidCacheBackendError(ImproperlyConfigured):
@@ -45,7 +45,7 @@ def get_key_func(key_func):
if callable(key_func):
return key_func
else:
- return import_by_path(key_func)
+ return import_string(key_func)
return default_key_func