[ZODB-Dev] transaction observer iface

hazmat at objectrealms.net hazmat at objectrealms.net
Sat Feb 21 08:20:24 EST 2004


> Kapil Thangavelu wrote at 2004-2-20 12:40 -0500:
>>i'm interested in implementing an observer interface for transactions,
>
> This is difficult as transactions are usually implicitly created.
> Especially the "notifyBegin" seems doubtful in the "implicitly created"
> case.

agreed.

>
> As Shane already pointed out: transactions already support notification
> for most of the events listed (not for begin, not for "objectRegistered").

as noted in my other email, the timing of those events for data managers
is such that its not safe/determinstic for modifying application data.
take the example of txn.commit() which would translate into an initial
message of tpc_begin to data managers, if an observer masquerades as a
data manager and recieves this message and wants to change application
state which might possibly store data to a different data manager than the
tpc protocol would be broken because the new data manager would never
recieve tpc_begin.

as for some recent real world use cases where this has come up, one was a
system which involved object annotations on objects from a different data
manager, another is a versioning system with a copy on write model (for
efficient snapshot of system state) where changesets need to be recorded
to increment/store versions of objects appropriately.

> I would not need additional notifications.
>
> If you implement "notifyObjectRegistered", you should ensure
> that it does not significantly slows down normal operation (which
> has no need for this event).
>

this has been my primary concern about adding this interface, namely
efficiency, for all notifications the cost without observers is a simple
conditional expression (if self.observers)

i'll implement and maintain as a patch for now.

-kapil



More information about the ZODB-Dev mailing list