On Tue, 2011-11-15 at 11:44 -0600, Michael Merickel wrote:
> It's been hard to follow what has actually been tried, but I just
> wanted to point some stuff out about zope.sqlalchemy (the code for it
> is literally 1 small file and shouldn't be talked about with such a
> scary tone).
> 
> 
> When doing transaction.savepoint() it returns a savepoint object that
> calls "session.begin_nested()". and when you call rollback on that
> savepoint object it calls "session.rollback()". I think that is
> identical to SQLAlchemy's expected use. For example:
> 
> 
> sp = transaction.savepoint() # session.begin_nested()
> try:
>     # do stuff
> except IntegrityError:
>     sp.rollback() # session.rollback()
> 
> 
> # do more stuff
> transaction.commit() # or ideally don't commit and let pyramid_tm do
> that part for you

Vlad: it'd be useful to know whether this (savepoint.rollback()) doesn't
work for you (as opposed to using session.rollback()).

- C


> 
> On Tue, Nov 15, 2011 at 9:19 AM, Michael Bayer
> <[email protected]> wrote:
>         
>         On Nov 15, 2011, at 7:09 AM, Vlad K. wrote:
>         
>         >
>         >
>         > Why I didn't think of this earlier? Transaction complains if
>         you use session.commit() or session.begin_nested() directly,
>         wants you to use transaction.commit() and
>         transaction.savepoint() instead and it just didn't occur to me
>         to try session.rollback() nevertheless (and in my mind
>         transaction.abort() == session.rollback() which now I see is
>         NOT the same), and trying savepoint.rollback() fails, I
>         assumed session.rollback() was called by Transaction since the
>         SQL debug output clearly shows savepoint rollback being
>         emitted, so I went to search for another solution.
>         >
>         > Aside from me being silly for not trying this before (and it
>         is even suggested by the InvalidRequestError!), it is a bit
>         illogical to have to use transaction.savepoint() and then use
>         session.rollback() instead of savepoint.rollback().
>         
>         
>         
>         glad you figured this out.   Now we need to adjust
>         zope.sqlalchemy's API and/or documentation so that the
>         SAVEPOINT use case is made clear.    I would think that since
>         SAVEPOINTs can be per-connection,  perhaps zope.sqlalchemy
>         would support begin_nested() on individual sessions...or maybe
>         not.
>         
>         
>         --
>         You received this message because you are subscribed to the
>         Google Groups "pylons-discuss" group.
>         To post to this group, send email to
>         [email protected].
>         To unsubscribe from this group, send email to pylons-discuss
>         [email protected].
>         For more options, visit this group at
>         http://groups.google.com/group/pylons-discuss?hl=en.
>         
>         
> 
> 
> 
> 
> -- 
> 
> Michael
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to pylons-discuss
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to