diff options
author | drebs <drebs@leap.se> | 2013-01-08 16:12:41 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-01-08 16:12:41 -0200 |
commit | 144a410948b83fc48a50042561b6e439c94ecbf5 (patch) | |
tree | bed99f987fea68401c22478c9cda0f0d415230ab /backends/objectstore.py | |
parent | c8dd8908ee11d1ef057b1d439d3fe12ad50c5071 (diff) |
Refactor and details of ObjectStore and CouchDatabase
Diffstat (limited to 'backends/objectstore.py')
-rw-r--r-- | backends/objectstore.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/backends/objectstore.py b/backends/objectstore.py index 9fce88f6..54ffa9dd 100644 --- a/backends/objectstore.py +++ b/backends/objectstore.py @@ -9,13 +9,14 @@ class ObjectStore(CommonBackend): A backend for storing u1db data in an object store. """ - def __init__(self): + def __init__(self, replica_uid=None): # This initialization method should be called after the connection # with the database is established, so it can ensure that u1db data is # configured and up-to-date. self.set_document_factory(Document) self._sync_log = soledadutil.SyncLog() self._transaction_log = soledadutil.TransactionLog() + self._replica_uid = replica_uid self._ensure_u1db_data() #------------------------------------------------------------------------- @@ -183,7 +184,8 @@ class ObjectStore(CommonBackend): """ Create u1db data object in store. """ - self._replica_uid = uuid.uuid4().hex + if self._replica_uid is None: + self._replica_uid = uuid.uuid4().hex doc = self._factory(doc_id=self.U1DB_DATA_DOC_ID) doc.content = { 'transaction_log' : [], 'sync_log' : [], @@ -200,11 +202,14 @@ class ObjectStore(CommonBackend): """ Save u1db configuration data on backend storage. """ - doc = self._factory(doc_id=self.U1DB_DATA_DOC_ID) - doc.content = { 'transaction_log' : self._transaction_log.log, - 'sync_log' : self._sync_log.log, - 'replica_uid' : self._replica_uid, - '_rev' : self._couch_rev} - self._put_doc(doc) + NotImplementedError(self._set_u1db_data) + + def _set_replica_uid(self, replica_uid): + self._replica_uid = replica_uid + self._set_u1db_data() + def _get_replica_uid(self): + return self._replica_uid + replica_uid = property( + _get_replica_uid, _set_replica_uid, doc="Replica UID of the database") |