Add a calling card to @transaction for runtime determination.

This commit is contained in:
voussoir 2022-03-22 22:17:32 -07:00
parent 9c9123e2d2
commit 1026d4414c
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -45,6 +45,10 @@ def transaction(method):
This decorator adds the keyword argument 'commit' to your function, so that
callers can commit it immediately.
This decorator adds the attribute 'is_worms_transaction = True' to your
function. You can use this to distinguish readonly vs writing methods during
runtime.
If you want to raise an exception without rolling back, you can return
worms.raise_without_rollback(exc). This could be useful if you want to
preserve some kind of attempted action in the database while still raising
@ -81,6 +85,7 @@ def transaction(method):
database.release_savepoint(savepoint=savepoint_id)
return result
wrapped_transaction.is_worms_transaction = True
return wrapped_transaction
class Database(metaclass=abc.ABCMeta):