Commits

Alexander Solovyov  committed 150cff8

cleanup contrib.cache init

  • Participants
  • Parent commits 3e0c228

Comments (0)

Files changed (1)

File svarga/contrib/cache/__init__.py

 from cgi import parse_qsl
 
 from svarga.core.exceptions import ImproperlyConfigured
-from svarga.utils.imports import import_module, import_attribute
+from svarga.utils.imports import import_attribute
 
 BACKENDS = {
     'locmem': 'svarga.contrib.cache.backends.locmem.Provider',
         raise ImproperlyConfigured('Missing cache url definition in'
                                    'local settings')
     if '://' not in cache_url:
-        raise InvalidCacheBackendError('Cache URL must start with scheme://')
+        raise ImproperlyConfigured('Cache URL must start with scheme://')
 
     scheme, host = cache_url.split('://', 1)
     if '?' in host:
         params = dict(parse_qsl(params))
     else:
         params = {}
-
     host = host.rstrip('/')
 
-    if scheme in BACKENDS:
-        provider = import_attribute(BACKENDS[scheme])
-    else:
-        provider = import_attribute(scheme)
-
+    provider = import_attribute(BACKENDS.get(scheme, scheme))
     env_class.cache = provider(host, params)