Jim Fulton  <[EMAIL PROTECTED]> wrote:
> I propose to add a pre-commit hook to ZODB.

+1 of course.

> 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.

The hook probably may want to be called with the transaction object
itself as arguments, or is it a YAGNI? I'm saying this because
synchronizers are passed the transaction, OTOH this is at a slightly
higher level and we may not care about the transaction.

>            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.)

Yes, that's exactly what I was doing for my post-publishing hook called by 
Publish.py

>            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)?

Yes I'll look at it.

Florent

> I'd like to get this into ZODB 3.4.
> 
> Jim

-- 
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:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to