Allow custom undo managers in database plugins
Add a _create_undo_manager method in DbGeneric which can be overridden to supply a custom undo manager rather than the default DbGenericUndo.
This commit is contained in:
parent
626a96580a
commit
6d8b93ce84
@ -626,11 +626,11 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
self._set_save_path(directory)
|
self._set_save_path(directory)
|
||||||
|
|
||||||
if self._directory:
|
if self._directory and self._directory != ":memory:":
|
||||||
self.undolog = os.path.join(self._directory, DBUNDOFN)
|
self.undolog = os.path.join(self._directory, DBUNDOFN)
|
||||||
else:
|
else:
|
||||||
self.undolog = None
|
self.undolog = None
|
||||||
self.undodb = DbGenericUndo(self, self.undolog)
|
self.undodb = self._create_undo_manager()
|
||||||
self.undodb.open()
|
self.undodb.open()
|
||||||
|
|
||||||
# Other items to load
|
# Other items to load
|
||||||
@ -665,6 +665,12 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self.close()
|
self.close()
|
||||||
raise DbUpgradeRequiredError(dbversion, self.VERSION[0])
|
raise DbUpgradeRequiredError(dbversion, self.VERSION[0])
|
||||||
|
|
||||||
|
def _create_undo_manager(self):
|
||||||
|
"""
|
||||||
|
Create the undo manager.
|
||||||
|
"""
|
||||||
|
return DbGenericUndo(self, self.undolog)
|
||||||
|
|
||||||
def _close(self):
|
def _close(self):
|
||||||
"""
|
"""
|
||||||
Close database backend.
|
Close database backend.
|
||||||
|
@ -125,6 +125,13 @@ class DbUndo(metaclass=ABCMeta):
|
|||||||
txn.set_description(msg)
|
txn.set_description(msg)
|
||||||
txn.timestamp = time.time()
|
txn.timestamp = time.time()
|
||||||
self.undoq.append(txn)
|
self.undoq.append(txn)
|
||||||
|
self._after_commit(txn)
|
||||||
|
|
||||||
|
def _after_commit(self, transaction):
|
||||||
|
"""
|
||||||
|
Post-transaction commit processing.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def undo(self, update_history=True):
|
def undo(self, update_history=True):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user