Commit e491060e authored by Grégory Wisniewski's avatar Grégory Wisniewski

Add Storage.importFrom() API to import only a part of a storage.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1980 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 90b46901
...@@ -137,7 +137,14 @@ class Storage(BaseStorage.BaseStorage, ...@@ -137,7 +137,14 @@ class Storage(BaseStorage.BaseStorage,
self.app.sync() self.app.sync()
def copyTransactionsFrom(self, source, verbose=False): def copyTransactionsFrom(self, source, verbose=False):
return self.app.copyTransactionsFrom(source, self.tryToResolveConflict) """ Zope compliant API """
return self.app.importFrom(source, None, None,
self.tryToResolveConflict)
def importFrom(self, source, start=None, stop=None):
""" Allow import only a part of the source storage """
return self.app.importFrom(source, start, stop,
self.tryToResolveConflict)
def restore(self, oid, serial, data, version, prev_txn, transaction): def restore(self, oid, serial, data, version, prev_txn, transaction):
raise NotImplementedError raise NotImplementedError
......
...@@ -1015,7 +1015,7 @@ class Application(object): ...@@ -1015,7 +1015,7 @@ class Application(object):
return history_list return history_list
def copyTransactionsFrom(self, source, tryToResolveConflict): def importFrom(self, source, start, stop, tryToResolveConflict):
serials = {} serials = {}
def updateLastSerial(oid, result): def updateLastSerial(oid, result):
if result: if result:
...@@ -1026,7 +1026,7 @@ class Application(object): ...@@ -1026,7 +1026,7 @@ class Application(object):
for oid, serial in result: for oid, serial in result:
assert isinstance(serial, str), serial assert isinstance(serial, str), serial
serials[oid] = serial serials[oid] = serial
transaction_iter = source.iterator() transaction_iter = source.iterator(start, stop)
for transaction in transaction_iter: for transaction in transaction_iter:
self.tpc_begin(transaction, transaction.tid, transaction.status) self.tpc_begin(transaction, transaction.tid, transaction.status)
for r in transaction: for r in transaction:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment