summaryrefslogtreecommitdiff
path: root/src/leap/soledad/server
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-07-07 02:58:09 -0300
committerdrebs <drebs@leap.se>2017-07-18 15:30:30 -0300
commit1aa9dee0ce87434188d37c821617caeff24fd70f (patch)
treead95887aa4b7c598390d994aaa109bf8aa6e2fb9 /src/leap/soledad/server
parent679e1bb7990fc1fc9c4971db6383a75ae6acab80 (diff)
[feature] add namespace support for BlobsManager
'namespace' argument is supported by backend but not yet exposed on API for clients. Since IncomingBox makes heavy usage of it, this commit exposes the argument as a query string for clients to use it.
Diffstat (limited to 'src/leap/soledad/server')
-rw-r--r--src/leap/soledad/server/_blobs.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py
index 793149cd..7648e18e 100644
--- a/src/leap/soledad/server/_blobs.py
+++ b/src/leap/soledad/server/_blobs.py
@@ -184,23 +184,24 @@ class BlobsResource(resource.Resource):
def render_GET(self, request):
logger.info("http get: %s" % request.path)
- user, blob_id = self._validate(request)
+ user, blob_id, namespace = self._validate(request)
if not blob_id:
order = request.args.get('order_by', [None])[0]
- return self._handler.list_blobs(user, request, order_by=order)
+ return self._handler.list_blobs(user, request, namespace,
+ order_by=order)
self._handler.add_tag_header(user, blob_id, request)
- return self._handler.read_blob(user, blob_id, request)
+ return self._handler.read_blob(user, blob_id, request, namespace)
def render_DELETE(self, request):
logger.info("http put: %s" % request.path)
- user, blob_id = self._validate(request)
- self._handler.delete_blob(user, blob_id)
+ user, blob_id, namespace = self._validate(request)
+ self._handler.delete_blob(user, blob_id, namespace)
return ''
def render_PUT(self, request):
logger.info("http put: %s" % request.path)
- user, blob_id = self._validate(request)
- d = self._handler.write_blob(user, blob_id, request)
+ user, blob_id, namespace = self._validate(request)
+ d = self._handler.write_blob(user, blob_id, request, namespace)
d.addCallback(lambda _: request.finish())
d.addErrback(self._error, request)
return NOT_DONE_YET
@@ -214,7 +215,10 @@ class BlobsResource(resource.Resource):
for arg in request.postpath:
if arg and not VALID_STRINGS.match(arg):
raise Exception('Invalid blob resource argument: %s' % arg)
- return request.postpath
+ namespace = request.args.get('namespace', [''])[0]
+ if namespace and not VALID_STRINGS.match(namespace):
+ raise Exception('Invalid blob namespace: %s' % namespace)
+ return request.postpath + [namespace]
if __name__ == '__main__':