revitron.transaction

The transaction submodule contains a wrapper class to simplify the usage of transactions, transaction groups and subtransactions:

t = revitron.Transaction()
...
t.close()

Or alternatively you can also use the following syntax:

with revitron.Transaction():
    ...

A transaction group can be started using:

with revitron.TransactionGroup():
    ...

Classes:

BaseTransaction()

The base class for Revitron transaction classes.

Transaction([doc, suppressWarnings, ...])

A wrapper class for transactions and subtransactions.

TransactionGroup([doc])

The transaction group wrapper.

class BaseTransaction[source]

Bases: object

The base class for Revitron transaction classes. This class should not be used directly.

Methods:

__enter__()

Enter transaction context.

__exit__(execType, execValue, traceback)

Commit the transaction when leaving context.

__init__()

Init a basic transaction wrapper.

commit()

Commits the open transaction.

rollback()

Rolls back the open transaction.

__enter__()[source]

Enter transaction context.

__exit__(execType, execValue, traceback)[source]

Commit the transaction when leaving context.

__init__()[source]

Init a basic transaction wrapper.

commit()[source]

Commits the open transaction.

rollback()[source]

Rolls back the open transaction.

class Transaction(doc=None, suppressWarnings=False, rollbackOnError=False)[source]

Bases: BaseTransaction

A wrapper class for transactions and subtransactions. A subtransaction is started whenever there is already another active transaction in use. In case the transaction is not a subtransaction, it is possible to optionally suppress warnings and automatically roll back on errors.

Methods:

__enter__()

Enter transaction context.

__exit__(execType, execValue, traceback)

Commit the transaction when leaving context.

__init__([doc, suppressWarnings, ...])

Inits a new transaction.

commit()

Commits the open transaction.

rollback()

Rolls back the open transaction.

__enter__()

Enter transaction context.

__exit__(execType, execValue, traceback)

Commit the transaction when leaving context.

__init__(doc=None, suppressWarnings=False, rollbackOnError=False)[source]

Inits a new transaction.

Parameters
  • doc (object, optional) – An optional document to be used instead of the currently active one. Defaults to None.

  • suppressWarnings (bool, optional) – Optionally suppress any warning messages displayed during the transaction. Not available in subtransactions. Defaults to False.

  • rollbackOnError – (bool, optional): Optionally roll back automatically on errors. Not available in subtransactions. Defaults to False.

commit()

Commits the open transaction.

rollback()

Rolls back the open transaction.

class TransactionGroup(doc=False)[source]

Bases: BaseTransaction

The transaction group wrapper.

Methods:

__enter__()

Enter transaction context.

__exit__(execType, execValue, traceback)

Commit the transaction when leaving context.

__init__([doc])

Init a new transaction group.

assimilate()

Assimilates the open transaction group.

commit()

Commits the open transaction.

rollback()

Rolls back the open transaction.

__enter__()

Enter transaction context.

__exit__(execType, execValue, traceback)[source]

Commit the transaction when leaving context.

__init__(doc=False)[source]

Init a new transaction group.

Parameters

doc (bool, optional) – The document for the transaction. Defaults to False.

assimilate()[source]

Assimilates the open transaction group.

commit()

Commits the open transaction.

rollback()

Rolls back the open transaction.