[ZODB-Dev] before commit hook

Florent Guillaume fg at nuxeo.com
Mon Apr 25 12:41:53 EDT 2005


FYI in CPS we use a simple backport of the before commit hook to ZODB 3.2:
http://cvs.nuxeo.org/cgi-bin/viewcvs.cgi/CPS3/CPSCompat/PatchZODBTransaction.py?rev=1&view=markup

For now we use it to delay indexing of some objects to the end of the
transaction (to avoid indexing twice the same object for instance):
http://cvs.nuxeo.org/cgi-bin/viewcvs.cgi/CPS3/CPSCore/IndexationManager.py?rev=1&view=markup

To index something, code just has to do:
get_indexation_manager().push(ob)


In get_indexation_manager() I have to check if there is already a
registered IndexationManager hook with the transaction. I currently use
a hack, but what I'd need is a way to query the registered hooks. What
do people think of adding something like:

def getBeforeCommitHooksImplementing(self, class_):
    """Get the registered beforeCommit hooks subclassing class_."""
    return [(hook, args, kws) for hook, args, kws in self._before_commit
            if isintance(hook, class_)]

(Interfaces could probably be a better choice than classes.)
Or is it overengineering ? Maybe just a getBeforeCommitHooks that
returns self._before_commit ?

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the ZODB-Dev mailing list