[Zope3-dev] Re: ObjectHub should change data structure
Philipp von Weitershausen
philipp@weitershausen.de
Fri, 27 Jun 2003 10:29:25 -0500
Jim Fulton wrote:
> Phillip J. Eby wrote:
>
>> Just a thought, but given how much work generally has to be done to
>> associate an object with its context (i.e., path) in Zope, would it be
>> really such a bad thing to have objects know who their parent(s) are?
>
> This is a question that I ask myself regularly. :)
You are not the only one.
> o Requiring all objects to manage their parents
> would be intrusive. Zope 3 wants to avoid any
> requirements on content objects.
I agree.
Why not adapt the pattern we use with annotations for this?
IAttributeAnnotatable comes to mind. We could have a
IAttributeParentAware (please come up with a better name!), in which
case the machinery is allowed to set __parent__ or whatever else.
We could also have a regular IParentAware interface which defines
methods like getParent() and setParent() for objects that *would* like
to manage their parents in some way.
> <wave member="hands">
> Perhaps this could be mitigated by permanent
> decorators. Such decorators might even be
> used to avoid mixing in persistence in some cases.
>
> That is, when we add an object to a container and the
> object isn't parent aware, we put it in a decorator that
> is and we store the decorator in the container.
> </wave>
That sounds like a good idea and could be the fallback option, if the
object itself is not and does not want to be parent-aware. Maybe this is
even the only thing we need, plus it wouldn't be that far from what
we're doing now.
Philipp