maxon.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 GraphTransaction.Commit() to make them permanent, or GraphTransaction.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 (GraphTransaction.Commit() or GraphTransaction.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.

__del__()

__enter__()

__exit__(exc_type, exc_val, exc_tb)

__init__([src])

Initializes a transaction.

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.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.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.__del__()
GraphTransaction.__enter__()
GraphTransaction.__exit__(exc_type, exc_val, exc_tb)
GraphTransaction.__init__(src=None)

Initializes a transaction.

Parameters

src (maxon.GraphTransaction) – An optional transaction to re-use.