MCPcopy Create free account
hub / github.com/PyTables/PyTables / enable_undo

Method enable_undo

tables/file.py:2388–2486  ·  view source on GitHub ↗

Enable the Undo/Redo mechanism. This operation prepares the database for undoing and redoing modifications in the node hierarchy. This allows :meth:`File.mark`, :meth:`File.undo`, :meth:`File.redo` and other methods to be called. The filters argument, when s

(self, filters: Filters = Filters(complevel=1))

Source from the content-addressed store, hash-verified

2386 return MarkG(trans, _mark_name % mid, "Mark number %d" % mid, new=True)
2387
2388 def enable_undo(self, filters: Filters = Filters(complevel=1)) -> None:
2389 """Enable the Undo/Redo mechanism.
2390
2391 This operation prepares the database for undoing and redoing
2392 modifications in the node hierarchy. This
2393 allows :meth:`File.mark`, :meth:`File.undo`, :meth:`File.redo` and
2394 other methods to be called.
2395
2396 The filters argument, when specified,
2397 must be an instance of class Filters (see :ref:`FiltersClassDescr`) and
2398 is meant for setting the compression values for the action log. The
2399 default is having compression enabled, as the gains in terms of
2400 space can be considerable. You may want to disable compression if
2401 you want maximum speed for Undo/Redo operations.
2402
2403 Calling this method when the Undo/Redo mechanism is already
2404 enabled raises an UndoRedoError.
2405
2406 """
2407 maxundo = self.params["MAX_UNDO_PATH_LENGTH"]
2408
2409 class ActionLog(NotLoggedMixin, Table):
2410 pass
2411
2412 class ActionLogDesc(IsDescription):
2413 opcode = UInt8Col(pos=0)
2414 arg1 = StringCol(maxundo, pos=1, dflt=b"")
2415 arg2 = StringCol(maxundo, pos=2, dflt=b"")
2416
2417 self._check_open()
2418
2419 # Enabling several times is not allowed to avoid the user having
2420 # the illusion that a new implicit mark has been created
2421 # when calling enable_undo for the second time.
2422
2423 if self.is_undo_enabled():
2424 raise UndoRedoError("Undo/Redo feature is already enabled!")
2425
2426 self._markers: dict[str, int] = {}
2427 self._seqmarkers: list[int] = []
2428 self._nmarks = 0
2429 self._curtransaction = 0
2430 self._curmark = -1 # No marks yet
2431
2432 # Get the Group for keeping user actions
2433 try:
2434 tgroup = self.get_node(_trans_group_path)
2435 except NodeError:
2436 # The file is going to be changed.
2437 self._check_writable()
2438
2439 # A transaction log group does not exist. Create it
2440 tgroup = self._create_transaction_group()
2441
2442 # Create a transaction.
2443 self._trans = self._create_transaction(
2444 tgroup, self._curtransaction
2445 )

Callers 15

__init__Method · 0.95
test17_fileUndoClosedMethod · 0.80
test18_fileUndoROMethod · 0.80
test00_simpleMethod · 0.80
test01_twiceMethod · 0.80
test02_twice2Method · 0.80
test03_6times3marksMethod · 0.80
test04_6times3marksroMethod · 0.80
test05_destructiveMethod · 0.80
test05b_destructiveMethod · 0.80
test05c_destructiveMethod · 0.80
test05d_destructiveMethod · 0.80

Calls 12

_check_openMethod · 0.95
is_undo_enabledMethod · 0.95
get_nodeMethod · 0.95
_check_writableMethod · 0.95
_create_transactionMethod · 0.95
_create_markMethod · 0.95
FiltersClass · 0.85
UndoRedoErrorClass · 0.85
ActionLogClass · 0.85
_f_get_childMethod · 0.80
appendMethod · 0.45

Tested by 15

test17_fileUndoClosedMethod · 0.64
test18_fileUndoROMethod · 0.64
test00_simpleMethod · 0.64
test01_twiceMethod · 0.64
test02_twice2Method · 0.64
test03_6times3marksMethod · 0.64
test04_6times3marksroMethod · 0.64
test05_destructiveMethod · 0.64
test05b_destructiveMethod · 0.64
test05c_destructiveMethod · 0.64
test05d_destructiveMethod · 0.64
test05e_destructiveMethod · 0.64