diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-01 08:15:52 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-01 08:15:52 +0000 |
| commit | ec02cf7a856dcc2ebc4ec10a35d6e87c1400b8f6 (patch) | |
| tree | 7da6f92114004063fc6ca2d88a823708a62f6db7 /django/core/cache | |
| parent | 4d2de7a3074a56b8f373d3598dc36243091a4a45 (diff) | |
[1.0.X] Changed the way cache specifiers are parsed.
Allows us to reuse the same code in multiple places, avoiding new and
interesting bugs (the testing framework had a DIY version that was slightly
wrong, for example). Fixed #9833.
Backport of r9936 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9937 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/cache')
| -rw-r--r-- | django/core/cache/__init__.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index 93e7adb76e..23a61ef859 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -31,7 +31,12 @@ BACKENDS = { 'dummy': 'dummy', } -def get_cache(backend_uri): +def parse_backend_uri(backend_uri): + """ + Converts the "backend_uri" into a cache scheme ('db', 'memcached', etc), a + host and any extra params that are required for the backend. Returns a + (scheme, host, params) tuple. + """ if backend_uri.find(':') == -1: raise InvalidCacheBackendError, "Backend URI must start with scheme://" scheme, rest = backend_uri.split(':', 1) @@ -48,6 +53,10 @@ def get_cache(backend_uri): if host.endswith('/'): host = host[:-1] + return scheme, host, params + +def get_cache(backend_uri): + scheme, host, params = parse_backend_uri(backend_uri) if scheme in BACKENDS: module = __import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']) else: |
