summaryrefslogtreecommitdiff
path: root/src/leap/soledad/server/_blobs.py
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-07-05 02:17:38 -0300
committerdrebs <drebs@leap.se>2017-07-18 15:22:23 -0300
commit361eb8d7121cc8abb94d9fef784d5ff2b27722d0 (patch)
tree54f1fd298522303aec74a9a622e39f0cfb6800f5 /src/leap/soledad/server/_blobs.py
parentec8d1f5aedcd077b5b1521e15b1432e616f83f3a (diff)
[feature] add blobs as a incoming api backend
We started with CouchDB due legacy system relying on it. This commit adds the possibility of adding blobs as a IncomingAPI backend if blobs is enabled on config file. -- Resolves: #8868
Diffstat (limited to 'src/leap/soledad/server/_blobs.py')
-rw-r--r--src/leap/soledad/server/_blobs.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py
index f87c3818..87b171fb 100644
--- a/src/leap/soledad/server/_blobs.py
+++ b/src/leap/soledad/server/_blobs.py
@@ -237,3 +237,23 @@ if __name__ == '__main__':
factory = Site(root)
reactor.listenTCP(args.port, factory)
reactor.run()
+
+
+class BlobsServerState(object):
+ """
+ Given a backend name, it gives a instance of IBlobsBackend
+ """
+ # Allowed backend classes are defined here
+ handlers = {"filesystem": FilesystemBlobsBackend}
+
+ def __init__(self, backend, **backend_kwargs):
+ if backend not in self.handlers:
+ raise ImproperlyConfiguredException("No such backend: %s", backend)
+ self.backend = self.handlers[backend](**backend_kwargs)
+
+ def open_database(self, user_id):
+ """
+ That method is just for compatibility with CouchServerState, so
+ IncomingAPI can change backends.
+ """
+ return self.backend