Location-related events (was Re: [Zope3-dev] Using parent
references rather than context wrappers to represent containment)
Phillip J. Eby
pje at telecommunity.com
Wed Aug 13 14:39:13 EDT 2003
At 10:58 AM 8/13/03 -0400, Jim Fulton wrote:
>I worked up a preproposal on location-related events at:
>
> http://dev.zope.org/Zope3/LocationRelatedEvents
>
>I've conviced, based on this preliminary analysis, that containers cannot be
>responsible for generating location-change events.
Per our previous discussion, I disagree with "location implies traversal",
since a component may wish to use another component as its context, and yet
that context has no references to the component. So, if it's desired to
find all of the items that have a particular item as a parent, some kind of
index would be needed.
However, it's not clear to me *why* that's needed. That is, I'm not sure
what the use case is for propagating an event to all descendants of a
container. It seems to me that one would simply tell the container that
the object is moving, and the object that it's moving, and leave it to the
container to tell its parents (if applicable) and the object to notify its
children (if desirable), and maybe you'd notify the system event service,
so any other interested parties could know about it.
As far as the event structure... in ZPatterns I found it useful to
structure the event differently according to who was receiving it. I don't
know if this will do what you want, but anyway, what I did was that each
recipient saw the event from its own point of view. Let's say that you had
this structure:
A
/ \
B C
And you moved an object O from folder B to folder C. A received an event
that said "O moved from B to C", while B received an event that said "O has
been removed", and C received an event that said "O has just arrived". The
purpose of this is that if B and C have local invariants to preserve
regarding their contents, they are seeing the right kind of event, from
their local perspective. Meanwhile, A could maintain any location-based
things, but would not think an object had been created or destroyed.
Perhaps this is the sort of event structure you are looking for?
More information about the Zope3-dev
mailing list