diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-05-23 04:53:10 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-05-23 04:58:22 -0300 |
commit | 773b96796dfaa2e43c9d16d1a1cdbd609a520056 (patch) | |
tree | e50da0a510326bcf3e87746b47a59b54391d82be /server | |
parent | f9fbae0e6296382dd558ba12c1acc646447cc8cd (diff) |
[refactor] improve backend naming and error handling
Diffstat (limited to 'server')
-rw-r--r-- | server/src/leap/soledad/server/_blobs.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/server/src/leap/soledad/server/_blobs.py b/server/src/leap/soledad/server/_blobs.py index 27e79736..10678360 100644 --- a/server/src/leap/soledad/server/_blobs.py +++ b/server/src/leap/soledad/server/_blobs.py @@ -149,6 +149,10 @@ class FilesystemBlobsBackend(object): return self._validate_path(path, user, blob_id) +class ImproperlyConfiguredException(Exception): + pass + + class BlobsResource(resource.Resource): isLeaf = True @@ -156,11 +160,13 @@ class BlobsResource(resource.Resource): # Allowed backend classes are defined here handlers = {"filesystem": FilesystemBlobsBackend} - def __init__(self, backend, blobs_path, **backend_args): + def __init__(self, backend, blobs_path, **backend_kwargs): resource.Resource.__init__(self) self._blobs_path = blobs_path - backend_args.update({'blobs_path': blobs_path}) - self._handler = self.handlers[backend](**backend_args) + backend_kwargs.update({'blobs_path': blobs_path}) + if backend not in self.handlers: + raise ImproperlyConfiguredException("No such backend: %s", backend) + self._handler = self.handlers[backend](**backend_kwargs) assert interfaces.IBlobsBackend.providedBy(self._handler) # TODO double check credentials, we can have then |