From 22d517e97d81c5630b85dbf55c40f2716d608e96 Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 3 Dec 2012 15:26:37 -0200 Subject: Add method get_doc for OpenStack backend --- src/leap/soledad/openstack.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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.""" -- cgit v1.2.3