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
Constructor
- Parameters:
configuration (BaseConfiguration)
policy (Optional[InvalidValuePolicy])
- __init__(configuration, policy=None)[source]
Create a transaction for
configurationand its root tree.policyis shared by every staged value in a high-level mutation. When omitted, the transaction uses a strict policy for direct, low-level staging.- Parameters:
configuration (BaseConfiguration)
policy (Optional[InvalidValuePolicy])
- Return type:
None
- class _Boundary(transaction)[source]
Change-stack marker and explicit savepoint context.
- Parameters:
transaction (ConfigurationTransaction)
- 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.
policyis used only when a new transaction is created; nested operations share the policy of the active transaction.- Parameters:
configuration (BaseConfiguration)
policy (Optional[InvalidValuePolicy])
- Return type:
- _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 whenrollbackis true.- Parameters:
boundary (ase2sprkkr.common.configuration_transaction.ConfigurationTransaction._Boundary)
rollback (bool)
- Return type:
bool
- push(change)[source]
Push a staged change and return it; it must implement rollback.
- Parameters:
change (Any)
- Return type:
Any
- _rollback_after(boundary)[source]
Rollback changes above
boundary, leaving it active.- Parameters:
boundary (ase2sprkkr.common.configuration_transaction.ConfigurationTransaction._Boundary)
- Return type:
None