[Zope3-dev] Re: ObjectHub should change data structure

Shane Hathaway shane@zope.com
Fri, 27 Jun 2003 12:28:09 -0400


Jim Fulton wrote:
>     o We'd sort of like to allow an object to be able to
>       have more than one parent.  OTOH, while I'd like to
>       to be able to do so in theory, it is generally
>       inconvenient in practice.

I can think of three ways that Zope uses parentage:

- For security context.

- To compute the URL of the object.

- To compute an unchanging, "physical" path.

Zope 2 generally assumes that all of these parents are the same; 
'obj.aq_inner.aq_parent' is used for all three kinds of parents.  But in 
a current Zope 2 project, I had to break that assumption.  Let me try to 
explain why.

The project is a CMS with a repository model, where all content goes 
into a big bucket.  The big bucket is an important part of the 
architecture, since it facilitates staging and sharing content among 
sections.  Yet the customer also needed to be able to confine users to 
editing objects located in particular sections.  Zope's security model 
made this difficult.  We couldn't grant the limited users permissions 
for the entire repository.  Applying local roles to every object in the 
repository would be a burden, and wouldn't work if there are a lot of users.

It was very hard to reconcile the two requirements (big bucket and 
location-oriented security) until I stumbled on the idea of giving 
objects different parents for different purposes.  The security context 
changes according to the location through which the user views content 
objects, and content objects are allowed to be viewed through only 
particular contexts.  The URL also changes according to location.  The 
physical path of the object, on the other hand, refers to the repository 
and never changes.

So, using this model, let's say there is an object called "newsitem" 
stored in the repository at /article-bucket.  The user is viewing it 
through /regional/articles.  While viewing the object this way, it has 
the following characteristics:

- Its security context is /regional/articles

- Its URL is http://.../regional/articles/newsitem

- Its physical path is ('', 'article-bucket', 'newsitem')

Again, Zope 2 made it pretty hard to separate these concepts, but I 
eventually found a way to make it work (to my amazement. ;-) )  I'd like 
Zope 3 to allow a cleaner separation of parentage.

I got the idea of separating parentage from working with Javascript.  In 
recent browsers, each DOM node has two parents: the containing node and 
the offsetParent.  The two parents are often the same, but the offset 
parent may differ according to layout rules.  Real life has this same 
kind of separation, too: your biological parents might not be the 
parents who raise you.

Shane