Following a request[1] for savepoint release support in
zope.sqlalchemy, I've been looking into how this might be done. Adding
the necessary support to Zope's transaction module was quite simple
[2], but the mapping of Zope transaction savepoints -> SQLAlchemy
nested transactions -> database savepoints gives a problem...
How can I get SQLAlchemy to release a savepoint, without also
releasing all subsequent savepoints (the nested transactions? This is
demonstrated by the doctest below from my branch of Zope's transaction
module:
Savepoint release
-----------------
Some data managers may only support a limited number of savepoints.
>>> dm['bob-balance'] = 100.0
>>> dm['bob-balance']
100.0
>>> savepoint1 = transaction.savepoint()
>>> dm['bob-balance'] = 200.0
>>> dm['bob-balance']
200.0
>>> savepoint2 = transaction.savepoint()
>>> dm['bob-balance'] = 300.0
>>> dm['bob-balance']
300.0
>>> savepoint3 = transaction.savepoint()
To release resources on the data manager, a savepoint may be released:
>>> savepoint2.release()
The savepoint then becomes invalid and may no longer be used:
>>> savepoint2.rollback()
Traceback (most recent call last):
...
InvalidSavepointError
Subsequent savepoints remain valid:
>>> dm['bob-balance'] = 400.0
>>> dm['bob-balance']
400.0
>>> savepoint3.rollback()
>>> dm['bob-balance']
300.0
As do previous savepoints:
>>> savepoint1.rollback()
>>> dm['bob-balance']
100.0
>>> transaction.abort()
Laurence
[1] http://groups.google.com/group/sqlalchemy/browse_thread/thread/b2594ff621538f3f
[2] http://svn.zope.org/repos/main/transaction/branches/elro-savepoint-release
Hi,
Following a request[1] for savepoint release support in
zope.sqlalchemy, I've been looking into how this might be done. Adding
the necessary support to Zope's transaction module was quite simple
[2], but the mapping of Zope transaction savepoints -> SQLAlchemy
nested transactions -> database savepoints gives a problem...
How can I get SQLAlchemy to release a savepoint, without also
releasing all subsequent savepoints (the nested transactions? This is
demonstrated by the doctest below from my branch of Zope's transaction
module:
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Thanks for looking into this. I hadn't realized that subsequent
savepoints would also be destroyed. I'll make Zope's transaction
module match the PostgreSQL behaviour. As savepoints and nested
transactions are then equivalent I shouldn't need anything more from
SQLAlchemy.
Laurence