[Zope3-dev] publishEvent bubble pattern

Steve Alexander steve@cat-box.net
Thu, 18 Apr 2002 23:17:33 +0100


Gary Poster wrote:
>
> Does that method potentially get into threading issues?  I am not familiar
> with the concurrency guarantees.

As far as an individual instance is concerned, the ZODB runs 
single-threaded.

Each ZODB thread has its own copy of a particular instance. When 
different things happen to the different instances, only one of them 
"wins", and a conflict error is raised in the other threads for the 
transactions in which the other instances were modified.


> Is the idea that if a service asked a higher service to publish an event, it
> would then place the event in a personal holding bucket right before asking;
> order of execution would then mean that, if the higher service were to
> re-notify the requesting lower service, the lower service could check to see
> if the event were in the holding bucket, and if so, ignore the event; and
> when eventually program execution returned to the lower service after
> calling "publishEvent" it could immediately remove the event object from the
> bucket?  That sounds reasonable, but I just want to make sure that's where
> you're going, and that it is threadsafe etc.

Yes. For "holding bucket", just use a _v_currentEvent attribute. This 
attribute will not be persisted, although it can live longer than a 
single transaction.

--
Steve Alexander