On May 31, 2010, at 8:24 AM, Kent Bower wrote:

> Although sqla doesn't allow the user to specify the savepoint name, the same 
> could be accomplished given if support for the following were implemented:
> 
> Let me ask:
> 
> sp_a=begin_nested()
> ...
> ...
> sp_b=begin_nested()
> ...
> ...
> sp_c=begin_nested()
> ...
> ... #realize I need to go back to sp_a...
> sp_a.rollback()
> 
> My understanding from the docs, is this is no good currently.  I need to 
> first do commit(), commit() and then rollback() or three rollback()s, correct?
> 
> Again, I'm not requesting an enhancement, but would make the point that it 
> would be more *intuitive* for sqla to figure that out for you, so you could 
> arbitrarily say sp_a.rollback() and it knows to release or rollback all the 
> nested transactions living under sp_a.


that's how the engine-level API works - you get at a Transaction object that 
you can roll back anywhere in the chain (its up to you to know that the other 
Transaction objects in the middle are no longer valid).    In the ORM we wanted 
to keep things more simplistic.   I would note that begin() and begin_nested() 
do return the SessionTransaction object though, which does itself include 
commit() and rollback() methods.   You might want to try the above pattern with 
it, as it might accomplish this already ( I didn't write the SessionTransaction 
accounting logic).

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to