diff --git svarga contrib cache __init__ py svarga contrib cache __ini

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
diff --git a/svarga/contrib/cache/__init__.py b/svarga/contrib/cache/__init__.py
--- a/svarga/contrib/cache/__init__.py
+++ b/svarga/contrib/cache/__init__.py
@@ -8,6 +8,7 @@ from svarga.utils.imports import import_
BACKENDS = {
'locmem': 'svarga.contrib.cache.backends.locmem.Provider',
'dummy': 'svarga.contrib.cache.backends.dummy.Provider',
+ 'memcache': 'svarga.contrib.cache.backends.memcache.Provider',
}
def init(settings, env_class):
@@ -16,23 +17,17 @@ def init(settings, env_class):
if cache_url is None:
raise ImproperlyConfigured('Missing cache url definition in'
'local settings')
- if cache_url.find(':') == -1:
+ if cache_url.find('://') == -1:
raise InvalidCacheBackendError('Cache URL must start with scheme://')
- scheme, rest = cache_url.split(':', 1)
- if not rest.startswith('//'):
- raise InvalidCacheBackendError('Cache URL must start with scheme://')
-
- host = rest[2:]
- qpos = rest.find('?')
- if qpos != -1:
- params = dict(parse_qsl(rest[qpos+1:]))
- host = rest[2:qpos]
+ scheme, host = cache_url.split('://', 1)
+ if '?' in rest:
+ host, params = host.split('?', 1)
+ params = dict(parse_qsl(params))
else:
params = {}
- if host.endswith('/'):
- host = host[:-1]
+ host = host.rstrip('/')
if scheme in BACKENDS:
provider = import_attribute(BACKENDS[scheme])