[ZODB-Dev] Re: [Zope-dev] Re: post publishing hook

Jim Fulton jim at zope.com
Mon Apr 4 10:38:06 EDT 2005


Florent Guillaume wrote:
> Jeremy Hylton wrote:
> 
>>> Is there a way to hook before the first transaction commit phase ?
>>
>>
>> If you register a synchronizer with the transaction manager, it's
>> beforeCompletion() method will be called immediately before changing
>> the transaction's state to committing.  This hook was intended in part
>> to support use cases like "do something magic to the transaction
>> before it commits."  It looks like the registerSynch() method of the
>> transaction manager is undocumented, but that is an oversight.
> 
> 
> Ok, and I see that beforeCompletion(t) has to check t.status to find out 
> when it is called (if the transaction is ACTIVE it's ok, otherwise it's 
> been called by abort() -- the fact that abort() calls it should probably 
> be documented).

I think that this is not the right mechanism.  It's not really
intended for application code and is far to complex for what is,
IMO, a very simple case.

I'll make a proposal in a separate message.

> But as Julien said we'll have to find another way using ZODB 3.2...

Yes.

You could install your own get_transaction that returned a
wrapper transaction that called before-commit hooks before
calling the real commit.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the ZODB-Dev mailing list