[ZODB-Dev] transaction observer iface

Shane Hathaway shane at zope.com
Fri Feb 20 15:33:58 EST 2004


On Fri, 20 Feb 2004, Kapil Thangavelu wrote:

> i'm interested in implementing an observer interface for transactions,
> something along the apis of the following. i was curious if there was
> interest/support for this sort of development.

Every transaction participant is already an observer, isn't it?  It seems
like the only functionality you added is notifyObjectRegistered();  
everything else is accessible through tpc_*.  Maybe I misinterpreted.

> class ITransactionObserver:
> 
>     def notifyAbort( txn ):
>         """
>         invoked when the transaction is about to abort
>         """

FWIW, I've named event-ish methods notify*() in the past, but now I think
a much better convention is to name them before*() or after*().  So I
might name the methods of the interface beforeAbort(), beforeCommit(),
afterBegin(), and afterObjectRegistered().  The difference between before
and after is often important.  For example, before*() often allows veto,
while after*() usually doesn't.

Shane



More information about the ZODB-Dev mailing list