ConfigurationTransaction

class ase2sprkkr.common.configuration_transaction.ConfigurationTransaction(configuration, policy=None)[source]

Context manager for temporary configuration mutations.

Staged objects hold their proposed state directly, so ordinary container traversal sees the complete proposal. A normal context exit commits all staged objects; an exceptional exit rolls them back in reverse order.

Mutable values are the real objects. Their in-place mutations deliberately cannot be rolled back by this transaction.

Class hierarchy

Inheritance diagram of ase2sprkkr.common.configuration_transaction.ConfigurationTransaction


Constructor

Parameters:
__init__(configuration, policy=None)[source]

Create a transaction for configuration and its root tree.

policy is shared by every staged value in a high-level mutation. When omitted, the transaction uses a strict policy for direct, low-level staging.

Parameters:
Return type:

None

class _Boundary(transaction)[source]

Change-stack marker and explicit savepoint context.

Parameters:

transaction (ConfigurationTransaction)

rollback()[source]

Rollback changes registered since the savepoint was created.

classmethod current(configuration)[source]

Return the active transaction for configuration, if any.

Parameters:

configuration (BaseConfiguration)

Return type:

Optional[‘ConfigurationTransaction’]

classmethod use(configuration, policy=None)[source]

Return a context for the transaction applicable to configuration.

An active transaction is entered as a nested savepoint; otherwise a new transaction is returned. A failed nested operation rolls back only its own changes unless its exception escapes the outer transaction. policy is used only when a new transaction is created; nested operations share the policy of the active transaction.

Parameters:
Return type:

ConfigurationTransaction

_finish_stage()[source]

Report a standalone stage immediately.

Transactions created directly are strict low-level transactions. A policy supplied by Configuration._mutation() is reported only after the complete mutation, so its results can be aggregated.

Return type:

None

_leave(boundary, rollback)[source]

Close boundary, rolling it back when rollback is true.

Parameters:
Return type:

bool

_require_active()[source]
Return type:

None

push(change)[source]

Push a staged change and return it; it must implement rollback.

Parameters:

change (Any)

Return type:

Any

savepoint()[source]

Rollback newly registered changes if the enclosed operation fails.

Return type:

ase2sprkkr.common.configuration_transaction.ConfigurationTransaction._Boundary

abort()[source]

Roll back changes in the current transaction boundary.

Return type:

None

_current_boundary()[source]
Return type:

ase2sprkkr.common.configuration_transaction.ConfigurationTransaction._Boundary

_rollback_after(boundary)[source]

Rollback changes above boundary, leaving it active.

Parameters:

boundary (ase2sprkkr.common.configuration_transaction.ConfigurationTransaction._Boundary)

Return type:

None

_commit()[source]

Commit staged objects and collect their post-change hooks.

Return type:

Dict[Any, Callable[[Any], None]]

_run_hooks(hooks)[source]

Run registered hooks after closing the transaction.

Parameters:

hooks (Dict[Any, Callable[[Any], None]])

Return type:

None