I've added the code on a branch off 3.4:
Could someone check if it's suitable and merge it ?
Jim Fulton <[EMAIL PROTECTED]> wrote:
> I propose to add a pre-commit hook to ZODB.
> 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.
> 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
> Anyone up for implementing this (with a doctest, of course)?
> I'd like to get this into ZODB 3.4.
Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D
+33 1 40 33 71 59 http://nuxeo.com [EMAIL PROTECTED]
For more information about ZODB, see the ZODB Wiki:
ZODB-Dev mailing list - ZODB-Dev@zope.org