[Zope3-Users] Re: Events

Philipp von Weitershausen philipp at weitershausen.de
Thu Feb 22 09:05:29 EST 2007


On 22 Feb 2007, at 14:57 , David Johnson wrote:
>>> This is probably the approach I will follow, but what if I want  
>>> my container objects notified?
>>
>> I thought you don't... ?
> This is both a theory and practice question.  I want to make sure I  
> follow practices that will not lead me into trouble in the  
> future.   In this case I am likely to want an ObjectModifiedEvent  
> so that my objects can be saved if they are modified.  For example  
> if I edit an object via browser:editform, an ObjectModifiedEvent  
> will be sent.  I am not clear whether Zope will examine every  
> object in my container to see if it has an event handler for  
> ObjectModifiedEvent; which is what it seems to do now.

You still don't seem to be getting it. The dispatching to container  
subobjects only happens for Object*Moved*Events, not on  
ObjectModifiedEvents or any other events.

Also, objects don't "have event handlers". There is a certain class  
of events called "object events". Code that does something to objects  
(create them, add the to a container, modify them, etc.) is supposed  
to send events about this. Then there aree event handlers that react  
to this. The original object is completely unaware of both the fact  
that an event is being sent about it and the fact that event handlers  
react to this. And that's exactly the beauty of it. Events let you  
implement business logic completely outside of the data model.

For further understanding, I really do suggest reading my book, it's  
explained in detail there. Any further discussion w/o that background  
will likely end up in confusion.



More information about the Zope3-users mailing list