diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/leap/soledad/server/_blobs.py | 11 | ||||
-rw-r--r-- | server/src/leap/soledad/server/_resource.py | 11 | ||||
-rw-r--r-- | server/src/leap/soledad/server/auth.py | 4 |
3 files changed, 10 insertions, 16 deletions
diff --git a/server/src/leap/soledad/server/_blobs.py b/server/src/leap/soledad/server/_blobs.py index d5476aae..f50e3da8 100644 --- a/server/src/leap/soledad/server/_blobs.py +++ b/server/src/leap/soledad/server/_blobs.py @@ -35,10 +35,9 @@ from twisted.web.client import FileBodyProducer from twisted.web.server import NOT_DONE_YET from zope.interface import Interface, implementer -from leap.soledad.server._config import get_config -__all__ = ['BlobsResource', 'blobs_resource'] +__all__ = ['BlobsResource'] logger = Logger() @@ -199,12 +198,6 @@ class BlobsResource(resource.Resource): return self._handler.write_blob(user, blob_id, request) -# provide a configured instance of the resource -_config = get_config() -_path = _config['blobs_path'] -blobs_resource = BlobsResource(_path) - - if __name__ == '__main__': # A dummy blob server # curl -X PUT --data-binary @/tmp/book.pdf localhost:9000/user/someid @@ -220,7 +213,7 @@ if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() - parser.add_argument('--port', default=9000) + parser.add_argument('--port', default=9000, type=int) parser.add_argument('--path', default='/tmp/blobs/user') args = parser.parse_args() diff --git a/server/src/leap/soledad/server/_resource.py b/server/src/leap/soledad/server/_resource.py index 7a00ad9a..49c4b742 100644 --- a/server/src/leap/soledad/server/_resource.py +++ b/server/src/leap/soledad/server/_resource.py @@ -19,7 +19,6 @@ A twisted resource that serves the Soledad Server. """ from twisted.web.resource import Resource -from ._blobs import blobs_resource from ._server_info import ServerInfo from ._wsgi import get_sync_resource @@ -56,12 +55,12 @@ class SoledadResource(Resource): for the Soledad Server. """ - def __init__(self, enable_blobs=False, sync_pool=None): + def __init__(self, blobs_resource=None, sync_pool=None): """ Initialize the Soledad resource. - :param enable_blobs: Whether the blobs feature should be enabled. - :type enable_blobs: bool + :param blobs_resource: a resource to serve blobs, if enabled. + :type blobs_resource: _blobs.BlobsResource :param sync_pool: A pool to pass to the WSGI sync resource. :type sync_pool: twisted.python.threadpool.ThreadPool @@ -69,11 +68,11 @@ class SoledadResource(Resource): Resource.__init__(self) # requests to / return server information - server_info = ServerInfo(enable_blobs) + server_info = ServerInfo(bool(blobs_resource)) self.putChild('', server_info) # requests to /blobs will serve blobs if enabled - if enable_blobs: + if blobs_resource: self.putChild('blobs', blobs_resource) # other requests are routed to legacy sync resource diff --git a/server/src/leap/soledad/server/auth.py b/server/src/leap/soledad/server/auth.py index b5744fe9..7f99e23d 100644 --- a/server/src/leap/soledad/server/auth.py +++ b/server/src/leap/soledad/server/auth.py @@ -39,6 +39,7 @@ from twisted.web.resource import IResource from leap.soledad.common.couch import couch_server from ._resource import SoledadResource, SoledadAnonResource +from ._blobs import BlobsResource from ._config import get_config @@ -53,10 +54,11 @@ class SoledadRealm(object): if conf is None: conf = get_config() blobs = conf['blobs'] + blobs_resource = BlobsResource(conf['blobs_path']) if blobs else None self.anon_resource = SoledadAnonResource( enable_blobs=blobs) self.auth_resource = SoledadResource( - enable_blobs=blobs, + blobs_resource=blobs_resource, sync_pool=sync_pool) def requestAvatar(self, avatarId, mind, *interfaces): |