On Sun, 2011-11-13 at 18:38 +0100, Vlad K. wrote:
> Hi, thanks for joining us here. :)
> 
> Yes, zope.transaction does indeed support savepoints:
> 
> somesavepoint = transaction.savepoint()
> 
> 
> And indeed I can see it being emitted in the SQL debug output:
> 
> 
> 2011-11-13 15:59:57,895 INFO  [sqlalchemy.engine.base.Engine][worker 0] 
> SAVEPOINT sa_savepoint_1
> 2011-11-13 15:59:57,896 INFO  [sqlalchemy.engine.base.Engine][worker 0] {}
> 2011-11-13 15:59:57,896 INFO  [sqlalchemy.engine.base.Engine][worker 0] 
> INSERT INTO user_stats (user_id, tstamp, portal, ads_new, ads_modified) 
> VALUES (%(user_id)s, %(tstamp)s, %(portal)s, %(ads_new)s, %(ads_modified)s)
> 2011-11-13 15:59:57,897 INFO  [sqlalchemy.engine.base.Engine][worker 0] 
> {'ads_modified': 0, 'user_id': 1, 'ads_new': 0, 'portal': 'XXXXXX', 
> 'tstamp': datetime.date(2011, 11, 13)}
> 2011-11-13 15:59:57,898 INFO  [sqlalchemy.engine.base.Engine][worker 0] 
> ROLLBACK TO SAVEPOINT sa_savepoint_1
> 2011-11-13 15:59:57,898 INFO  [sqlalchemy.engine.base.Engine][worker 0] {}
> 2011-11-13 15:59:57,904 INFO  [sqlalchemy.engine.base.Engine][worker 0] 
> BEGIN (implicit)
> 2011-11-13 15:59:58,100 ERROR [pyramid_debugtoolbar][worker 0] Exception 
> at http://localhost:6543/ads/view/28328?category=
> 
> The exception thrown in the last line is
> 
> TransactionFailedError: An operation previously failed, with traceback
> 
> And the traceback ends with:
> 
> IntegrityError: (IntegrityError) duplicate key value violates unique 
> constraint "user_stats_pkey"
> 
> Stemming from the transaction.commit() I manually issue in order to 
> match (in number) against savepoints issued. Even if I remove it 
> manually, it will still be called (and cause the exception) by the 
> transaction middleware outside of the request handler.
> 
> 
> But that IntegrityError has been caught (right when the ROLLBACK is 
> issued above). Also the ROLLBACK is apparently done automatically by 
> zope.transaction because if I try it manually:
> 
> savepoint.rollback()
> 
> 
> I get InvalidSavepointRollbackError
> 
> 
> I tried pretty much every combo of with and without savepoints, manual 
> or automatic flushin, commits, rollbacks and aborts, I just can't get 
> the request to complete without any exceptions.

I hate to ask, but would it be possible to concoct a short Python script
that creates a SQLA DBSession (with the ZopeTransactionExtension
enabled) that issues transaction.commit/savepoint/abort commands that
demonstrates the problem being encountered?  I'd be guessing if I tried
to help with this without that.

- C


-- 
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