diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
| commit | aa239e3e5405933af6a29dac3cf587b59a099927 (patch) | |
| tree | ea2cbd139c9a8cf84c09e0b2008bff70e05927ef /django/core/cache/__init__.py | |
| parent | 45b73c9a4685809236f84046cc7ffd32a50db958 (diff) | |
gis: Merged revisions 7981-8001,8003-8011,8013-8033,8035-8036,8038-8039,8041-8063,8065-8076,8078-8139,8141-8154,8156-8214 via svnmerge from trunk.archive/attic/gis
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@8215 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/cache/__init__.py')
| -rw-r--r-- | django/core/cache/__init__.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index 495cc92822..c136ce4f4d 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -19,8 +19,10 @@ from cgi import parse_qsl from django.conf import settings from django.core.cache.backends.base import InvalidCacheBackendError +# Name for use in settings file --> name of module in "backends" directory. +# Any backend scheme that is not in this dictionary is treated as a Python +# import path to a custom backend. BACKENDS = { - # name for use in settings file --> name of module in "backends" directory 'memcached': 'memcached', 'locmem': 'locmem', 'file': 'filebased', @@ -28,24 +30,12 @@ BACKENDS = { 'dummy': 'dummy', } -DEPRECATED_BACKENDS = { - # deprecated backend --> replacement module - 'simple': 'locmem', -} - def get_cache(backend_uri): if backend_uri.find(':') == -1: raise InvalidCacheBackendError, "Backend URI must start with scheme://" scheme, rest = backend_uri.split(':', 1) if not rest.startswith('//'): raise InvalidCacheBackendError, "Backend URI must start with scheme://" - if scheme in DEPRECATED_BACKENDS: - import warnings - warnings.warn("'%s' backend is deprecated. Use '%s' instead." % - (scheme, DEPRECATED_BACKENDS[scheme]), DeprecationWarning) - scheme = DEPRECATED_BACKENDS[scheme] - if scheme not in BACKENDS: - raise InvalidCacheBackendError, "%r is not a valid cache backend" % scheme host = rest[2:] qpos = rest.find('?') @@ -57,7 +47,10 @@ def get_cache(backend_uri): if host.endswith('/'): host = host[:-1] - cache_class = getattr(__import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']), 'CacheClass') - return cache_class(host, params) + if scheme in BACKENDS: + module = __import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']) + else: + module = __import__(scheme, {}, {}, ['']) + return getattr(module, 'CacheClass')(host, params) cache = get_cache(settings.CACHE_BACKEND) |
