diff options
author | drebs <drebs@leap.se> | 2012-12-03 15:26:37 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2012-12-03 15:26:37 -0200 |
commit | 22d517e97d81c5630b85dbf55c40f2716d608e96 (patch) | |
tree | ecb3fda05abef7e3dd072533fcc49fe476c64e8a /src | |
parent | d6196f88f390d1ee8d4a3f26aa4881fe15bcd2e0 (diff) |
Add method get_doc for OpenStack backend
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/soledad/openstack.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/leap/soledad/openstack.py b/src/leap/soledad/openstack.py index 9a8a6166..9bb4fddd 100644 --- a/src/leap/soledad/openstack.py +++ b/src/leap/soledad/openstack.py @@ -7,11 +7,12 @@ from swiftclient import client class OpenStackDatabase(CommonBackend): """A U1DB implementation that uses OpenStack as its persistence layer.""" - def __init__(self, auth_url, user, auth_key): + def __init__(self, auth_url, user, auth_key, container): """Create a new OpenStack data container.""" self._auth_url = auth_url self._user = user self._auth_key = auth_key + self._container = container self.set_document_factory(LeapDocument) self._connection = swiftclient.Connection(self._auth_url, self._user, self._auth_key) @@ -31,7 +32,11 @@ class OpenStackDatabase(CommonBackend): raise NotImplementedError(self.whats_changed) def get_doc(self, doc_id, include_deleted=False): - raise NotImplementedError(self.get_doc) + # TODO: support deleted docs? + headers = self._connection.head_object(self._container, doc_id) + rev = headers['x-object-meta-rev'] + response, contents = self._connection.get_object(self._container, doc_id) + return self._factory(doc_id, rev, contents) def get_all_docs(self, include_deleted=False): """Get all documents from the database.""" |