Re: what does transaction.abort() refresh?
Jim Fulton <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <CAPDm-FhT3Y7nkjJtLjEcDSvA-Ce+HSZMNxh3W+UbuWg=eYURYw@mail.gmail.com> |
On Wed, Oct 5, 2016 at 5:58 PM, Boylan, Ross <[email protected]> wrote: > OK, I RTFM http://www.zodb.org/en/latest/guide/transactions-and-threading.html#explicit-transaction-managers and see I'm definitely not doing that. Will try it. I wasn't suggesting that you should use explicit transaction managers. I was merely asking whether your connection was using the same transaction manager you were calling abort on. In typical applications, database code runs in some thread and uses the thread local transaction manager. In your original post, you didn't show how the connection object was created. If a connection is created like this: conn = db.open() Then it's using the the thread-local transaction manager. If you then called: transaction.abort() *in the same thread*, then you'd be calling abort on the same transaction manager that the connection was using. BTW, calling begin: transaction.begin() is better because it states the intent more clearly. Better yet: with db.transaction() as conn: ... do things with conn Is cleaner because it combines connection and transaction management, makes the transaction boundaries very explicit and even uses less code. Jim -- Jim Fulton http://jimfulton.info -- You received this message because you are subscribed to the Google Groups "zodb" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.