Rstransaction is a Python3.7+ toolbox to create transactional systems, for any kind of operations: in-memory, on filesystems, on remote storages…
It supports commits/rollbacks and savepoints.
It was never used in production, but is properly tested, and easily extendable to support different kinds of behaviour : immediate or lazy actions, recording of operations to disk files or DBs in case of crash, auto-rollback on error or not…
INSTALL
Using pip is recommended, although installing from a checkout of the repository (via setup.py) also works:
$ pip install rstransaction
USAGE
Your best bet is to read the sources (especially tests).
The idea is to create “atomic” operations using TransactionalActionAdapter. Each of these operations knows how to operate, how to rollback itself, and also how to preprocess its arguments so that they are unambiguous (ex. turn relative file names into absolute ones).
These actions are then registered near a TransactionalActionRegistry.
An action recorder has to be chosen (the default one, ActionRecorderBase, simply records actions in-memory, without persistence).
A transaction processor (inheriting TransactionBase) is then instantiated, and given the action registry as well as the action recorder. The default transaction processor, InteractiveTransaction, executes any operation (issued with tx_process_action()), immediately, so potential errors must be handled accordingly. But one could implement a transaction processor which delays all operations until commit time.
Transaction steps can be set manually (with tx_commit(), tx_rollback(), savepoint methods..), but the best is to use the transaction processor as a context manager (with keyword), so that full commit/rollback occur automatically on exit. The “tx_savepoint” attribute of transaction processor can also be used as a context manager, only acting on a savepoint this time.
A transaction processor automatically begins a new transaction, on commit or rollback, so it can be reused.
Note that exceptions do not get swallowed by this system, even if an automatic rollback occurs.
Subclasses of TransactionFailure are used to report errors linked to the transaction systemn, as exceptions.
Metadata
Release files for RSTransaction 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| rstransaction-0.3.tar.gz | 10.9 kB | Without provenance | Details |
Release files / rstransaction-0.3.tar.gz
| Download URL | rstransaction-0.3.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
792dab49b7b7a5d2df691a1ecdb3340cdd3f10fe1dee32ac9dcecf0841b5eac8
|
|
BLAKE2b-256 checksum How to use checksums |
53a63d93e0e6889da61cc6a7d3f8cb802fd077d67bd196c9e1e758cc662c6dac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for RSTransaction 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.