summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-05-12 03:51:00 -0300
committerVictor Shyba <victor1984@riseup.net>2017-05-12 03:51:00 -0300
commitf9fbae0e6296382dd558ba12c1acc646447cc8cd (patch)
tree92b461e5ee79edf74bd84c9290803228cc20e043 /server
parent6795f5ec9617afcded241efb328b396a83e77937 (diff)
[refactor] make blobs resource backend configurable
- Resolves: #8804
Diffstat (limited to 'server')
-rw-r--r--server/src/leap/soledad/server/_blobs.py12
-rw-r--r--server/src/leap/soledad/server/auth.py3
2 files changed, 8 insertions, 7 deletions
diff --git a/server/src/leap/soledad/server/_blobs.py b/server/src/leap/soledad/server/_blobs.py
index 74707111..27e79736 100644
--- a/server/src/leap/soledad/server/_blobs.py
+++ b/server/src/leap/soledad/server/_blobs.py
@@ -153,14 +153,14 @@ class BlobsResource(resource.Resource):
isLeaf = True
- # Allowed factory classes are defined here
- blobsFactoryClass = FilesystemBlobsBackend
+ # Allowed backend classes are defined here
+ handlers = {"filesystem": FilesystemBlobsBackend}
- def __init__(self, blobs_path):
- # TODO pass the backend as configurable option #8804
+ def __init__(self, backend, blobs_path, **backend_args):
resource.Resource.__init__(self)
self._blobs_path = blobs_path
- self._handler = self.blobsFactoryClass(blobs_path)
+ backend_args.update({'blobs_path': blobs_path})
+ self._handler = self.handlers[backend](**backend_args)
assert interfaces.IBlobsBackend.providedBy(self._handler)
# TODO double check credentials, we can have then
@@ -219,7 +219,7 @@ if __name__ == '__main__':
parser.add_argument('--path', default='/tmp/blobs/user')
args = parser.parse_args()
- root = BlobsResource(args.path)
+ root = BlobsResource("filesystem", args.path)
# I picture somethink like
# BlobsResource(backend="filesystem", backend_opts={'path': '/tmp/blobs'})
diff --git a/server/src/leap/soledad/server/auth.py b/server/src/leap/soledad/server/auth.py
index 7f99e23d..1357b289 100644
--- a/server/src/leap/soledad/server/auth.py
+++ b/server/src/leap/soledad/server/auth.py
@@ -54,7 +54,8 @@ class SoledadRealm(object):
if conf is None:
conf = get_config()
blobs = conf['blobs']
- blobs_resource = BlobsResource(conf['blobs_path']) if blobs else None
+ blobs_resource = BlobsResource("filesystem",
+ conf['blobs_path']) if blobs else None
self.anon_resource = SoledadAnonResource(
enable_blobs=blobs)
self.auth_resource = SoledadResource(