zope.sqlalchemy - commit some objects on failure

9 views
Skip to first unread message

Paul Johnston

unread,
Jan 6, 2013, 12:10:45 PM1/6/13
to sqlal...@googlegroups.com
Hi,

I'm using zope.sqlalchemy in a web application (actually ToscaWidgets not Zope) so each request is wrapped in a transaction. If the request succeeds the transaction is committed; if there is an error it is rolled back. This works great.

I have a log table where I log incoming XML to web callback methods (from eBay, 3DCart, etc.) Now, if there is an error what I want to happen is most things to be rolled back, but the log table still committed.

This has left me scratching my head a bit. Any ideas on an elegant way to do this?

Many thanks,

Paul


Michael Bayer

unread,
Jan 6, 2013, 7:18:15 PM1/6/13
to sqlal...@googlegroups.com
for this case you use a different Session, which you establish within the scope of the other one, add the state you want to it, and commit() it distinctly. Based on my limited experience with zope.transaction, this Session wouldn't even be using the zope.transaction extension so that it's own commit() method works normally.

the net effect of this is that your log operations occur on a different connection. I use this pattern for log tables extensively.



Reply all
Reply to author
Forward
0 new messages