[ZCM] [ZC] 2283/ 2 Reject "AssertionError: BeforeCommitHook with commit()"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Fri, 23 Feb 2007 17:31:13 -0500
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #2283 Update (Reject) "AssertionError: BeforeCommitHook with commit()"
Status Rejected, Zope/bug medium
To followup, visit:
http://www.zope.org/Collectors/Zope/2283
==============================================================
= Reject - Entry #2 by ajung on Feb 23, 2007 5:31 pm
Status: Pending => Rejected
You should not play tricks with the transaction machinery.
Commiting yourself with a ZODB commit hook is clearly a programming error.
________________________________________
= Request - Entry #1 by eikenberry on Feb 23, 2007 5:26 pm
If you add a function via the addBeforeCommitHook() that contains a transaction.get().commit(). It causes the folling traceback (from 2.9.6).
Error Type: AssertionError
Error Value:
Traceback (innermost last):
* Module ZPublisher.Publish, line 121, in publish
* Module Zope2.App.startup, line 240, in commit
* Module transaction._manager, line 96, in commit
* Module transaction._transaction, line 384, in commit
* Module transaction._manager, line 155, in free
AssertionError
This is due to the transaction's commit() being called twice which in turn calls the transaction manager's free() method twice causing the assertion error the second time for obvious reasons.
def free(self, txn):
tid = thread.get_ident()
assert txn is self._txns.get(tid)
del self._txns[tid]
==============================================================