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 | 802d3101eb1368eb52a195aee12368791edc64ac (patch) | |
tree | 76930a3696738d5af7d31cf90178bbe94a789d8e | |
parent | bb15b2eb975976c559d05d3bd8246811c0b666c6 (diff) |
Add method get_doc for OpenStack backend
-rw-r--r-- | openstack.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/openstack.py b/openstack.py index 9a8a6166..9bb4fddd 100644 --- a/openstack.py +++ b/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.""" |