maxon.frameworks.graph.GraphTransaction

Description

Modifications to a GraphModelInterface may only be done when there is an active GraphTransaction.

You start a transaction by calling GraphModelInterface.BeginTransaction() on the graph to modify.
When all modifications are done, you call GraphModelInterface.Commit() to make them permanent, or GraphModelInterface.Rollback() to return to the state of the graph when GraphModelInterface.BeginTransaction() has been called.

.. note::
Transactions can be nested.
A commit or rollback ends the current (innermost) transaction, but not enclosing transactions.
If a GraphTransaction goes out of scope but is still active (Commit() or Rollback() hasn’t been called), a rollback is triggered implicitly by the destructor.
This is important for error handling, as it implies that in case of an unhandled error an implicit rollback is made.
This prevents inconsistent states of the graph.

Inheritance diagram

Inheritance

Parent Class:

Methods Signature

Commit([userData])

Commits (end ends) this transaction.

GetGraph()

Returns the graph of this transaction, or a null reference when this transaction is inactive.

IsActive()

Checks if this transaction is active.

Rollback()

Rolls back the graph to its state at the time this transaction has been started, and ends this transaction.

__init__([src])

Initialize self.

Methods Definition

GraphTransaction.Commit(userData=None)
Commits (end ends) this transaction.
The changes made within this transaction become permanent in the graph (unless this is a nested transaction and an enclosing transaction is rolled back later).

If this transaction isn’t active, nothing happens.
Parameters

userData (maxon.DataDictionary) –

User data to pass to the observers of GraphModelInterface.ObservableTransactionCommitted.
This will be merged with all given user data of nested commits.

GraphTransaction.GetGraph()

Returns the graph of this transaction, or a null reference when this transaction is inactive.

Return type

maxon.frameworks.graph.GraphModelRef

Returns

Graph of transaction, or null reference.

GraphTransaction.IsActive()
Checks if this transaction is active.
A transaction is active between the initial call to GraphModelInterface.BeginTransaction() and the corresponding call to GraphModelInterface.Commit() or GraphModelInterface.Rollback().
Return type

maxon.frameworks.graph.GraphModelRef

Returns

True if this transaction is active otherwise False

GraphTransaction.Rollback()

Rolls back the graph to its state at the time this transaction has been started, and ends this transaction.

GraphTransaction.__init__(src=None)

Initialize self. See help(type(self)) for accurate signature.