[Zope3-dev] Using parent references rather than context wrappers to represent containment

Jim Fulton jim at zope.com
Mon Aug 11 07:25:23 EDT 2003


Steve Alexander wrote:
> 
>>     I'd really like to get comment on the issues above.  Absent,
>>     comment, here is how I'm thinking of resolving these issues:
>>
>>     1. Add responsability for collaborating with 'IContained' to
>>        'IContainer'.
> 
> 
> +1
> 
>>     2. Move responsability for generating modification events for
>>        containers back to application code.
> 
> 
> A container knows everything it needs in order to produce modification 
> events, so from that point of view, it should be in container code, not 
> application code.

OK

> Maybe we should consider "containment" to be a particular kind of 
> "relationship".

Certainly.

> The answer to this could be to decide how we want to tell the world 
> about changes to relationships, and then make containment relationships 
> just one case of this.

Perhaps. I'm note sure how this helps.  That is, we still have a depency
on a Zope facility.

> The need to send out Events might just be a policy of the 
> relationships-notification system.

I see the event system as lower level and more horizontal than
a relationship system.  I think I might rather depend on the
event system than the relationship system.


> 
>>     3. Optionally allow vies wo implement 'IContained' and add
>>        'IContained' support to BrowserView.
> 
> 
> A content object does not contain its views. In the proposal you said 
> "We don't want to mix up containment with other associations".

Right, it is a separate relationship.

> Although, I admit that a view looks a bit like containment:
> 
> - A view instance is found via a particular kind of traversal
>   from an object.
> - A view instance has only one "parent" or "container".
> 
> I guess we could have persistent view instances, although I can't think 
> of a good reason to want them just at the moment.

Nope.

> What name would you traverse on a content object to get to its views?
> "@@viewname" ?

That depends on the way you've configured your system. @@viewname is the
canonical form, although you can leave off the @@ when there is not danger
of a name conflict with contained items. For example, you generally don't
need the @@ for non-containers.

I'll note that we already context-wrap views, mainly because we create a context
wrapper for each step in a traversal.  When a view wants to access a service
or wants to acquire something, it uses it's context as the basis for the lookup.
I guess this is OK. There are a few views that use Context methods so that they
get passeded wrappers. I'm not sure that this is strictly necessary.

If views implemented IContained, then we could use the same API to acquire through
them that we use for traversing the containment hierarchy.  While a view isn't strictly
contained by it's context, the ability to use the same API seems beneficial.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (703) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Zope3-dev mailing list