-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I implemented a pre-commit hook on transaction supporting subscribers within CPS for our indexation use case. (for ZODB-3.2.x on Zope-2.7.x)
if you're interested to take a look at it : http://lists.nuxeo.com/pipermail/cps-devel/2005-April/001357.html The difference I can see with your proposal is the abort() hook facility that can be a good thing especially if the subscriber code has to communicate with external programs for rollback purpose. J. Jim Fulton wrote: > > I propose to add a pre-commit hook to ZODB. > > Problem > > Sometimes, applications want to execute some code when > a transaction is committed. For example, one might want to > delay object indexing until a transaction commits, rather > than indexing every time an object is changed. Or, someone > might want to check invariants only after a set of operations. > > Proposal > > We add a new method to transaction objects: > > def beforeCommitHook(hook, *args, **kw): > """Register a hook to call before the transaction is committed > > The provided hook will be called after the transaction's > commit method has been called, but before the commit process > has been started. The hook will be passed the given > positional and keyword arguments. > > Multiple hooks can be registered and will be called in order. > This method can be called from executing hooks. That is, > executing > hooks can register more hooks. (Applications should take care > to avoid creating infinite loops by recursvely registering > hooks.) > > Hooks are not called and are discarded if the transaction aborts. > """ > > We would also modify transaction commit methods to call hooks. Hooks > would > not be called on sub-transaction commit. (If necessary, we could add > separate sub-transaction hooks, but I don't think we need this.) > > This hook is very simple to use an implement and, I think, addresses > the requitement much more directly than implementing special data > managers. > > Thoughts? > > Anyone up for implementing this (with a doctest, of course)? > > I'd like to get this into ZODB 3.4. > > Jim > - -- Julien Anguenot | Nuxeo R&D (Paris, France) CPS Plateform : http://www.cps-project.org mail: anguenot at nuxeo.com; tel: +33 (0) 6 72 57 57 66 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCUXraGhoG8MxZ/pIRAsjtAJ4uKVSNOR3HcJT+pcCHKw8Xp4n+oACeMcxh E8OiBlgq0dF43tGRasJsjyU= =FLDY -----END PGP SIGNATURE----- _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev