[Zope3-dev] Please solve 'deleting container' issues ;-)

Steve Alexander steve@cat-box.net
Fri, 10 May 2002 14:48:57 +0100


Chris Withers wrote:
 > Janko Hauser wrote:
 >
 >>Ok, but I keep thinking, that this is only the technical side. This
 >>machinerie is not triggered, if I delete the hole container.
 >
 >
 > This is another problem that needs solving in Zope 3 ;-)
 >
 > For example, if I delete a ObjectManager (or whatever it is in Zope 
3), I want all the
 > objects contained in that ObjectManager to unindex themselves before 
they get deleted...

We're talking about removing rather than deleting.

One way of handling this involves an ObjectHub kind of thing, and a
special plug-in that knows about path locations.

When your container gets removed, an object removed event is sent into
the aether. The path-locations-aware plug-in sees that the object being
removed is a container, and infers that the container's sub-objects
will, by implication, be removed too.

So, this plug-in looks up the objects that you've registered an interest
in indexing, that are contained in the container, gets their ruids, and
sends out ruid object removed events for each of the contained object
that are indexed.


1: remove container
     - causes ObjectRemovedEvent to be sent to the EventService

2: The ObjectHub is subscribed for these events, so the EventService
     sends ObjectRemovedEvent to the ObjectHub

3: The ObjectHub generates an RuidObjectRemovedEvent for the container's
     location-independent Ruid.

4: The Path-Aware plug-in receives this RuidObjectRemovedEvent, and
     looks up what it knows about the ruid being removed. Aha! It's
     a Container. This Path-Aware plug-in knows about certain objects
     whose location-paths put them inside that container, so it
     generates ObjectRemovedEvents or RuidObjectRemoved events for
     these objects too.

     The kind of event generated depends whether you need this cascade to
     affect things outside the indexing machinery of the ObjectHub, or
     whether you only need indexes to be updated.

     Note that only those objects you've previously registered as being
     "interesting" for the object hub will have events sent on their
     behalf.


--
Steve Alexander