diff options
author | drebs <drebs@leap.se> | 2012-12-05 15:44:01 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2012-12-05 15:44:01 -0200 |
commit | d1bd08fd5952b8782e6fd59129fc4e2b15777617 (patch) | |
tree | 29cc40bd48201da3509caeba11e81e8c038f6713 /src | |
parent | e95726b8a7803dbb23bfca470cf4b665cf8559a4 (diff) |
Get doc split in two methods.
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/soledad/openstack.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/leap/soledad/openstack.py b/src/leap/soledad/openstack.py index 7b7e656f..a7220fa8 100644 --- a/src/leap/soledad/openstack.py +++ b/src/leap/soledad/openstack.py @@ -34,13 +34,24 @@ class OpenStackDatabase(CommonBackend): # easier like this for now, but it can be moved to here afterwards. return self._transaction_log.whats_changed(old_generation) - def get_doc(self, doc_id, include_deleted=False): - # TODO: support deleted docs? - headers = self._connection.head_object(self._container, doc_id) - rev = headers['x-object-meta-rev'] + def _get_doc(self, doc_id, check_for_conflicts=False): + """Get just the document content, without fancy handling. + + Conflicts do not happen on server side, so there's no need to check + for them. + """ response, contents = self._connection.get_object(self._container, doc_id) + rev = response['x-object-meta-rev'] return self._factory(doc_id, rev, contents) + def get_doc(self, doc_id, include_deleted=False): + doc = self._get_doc(doc_id, check_for_conflicts=True) + if doc is None: + return None + if doc.is_tombstone() and not include_deleted: + return None + return doc + def get_all_docs(self, include_deleted=False): """Get all documents from the database.""" raise NotImplementedError(self.get_all_docs) @@ -126,10 +137,6 @@ class OpenStackDatabase(CommonBackend): self._get_u1db_data() return self._transaction_log.get_generation_info() - def _get_doc(self, doc_id, check_for_conflicts=False): - """Get just the document content, without fancy handling.""" - raise NotImplementedError(self._get_doc) - def _has_conflicts(self, doc_id): raise NotImplementedError(self._has_conflicts) |