[Zope3-dev] Re: proposed changes to contained helper functions

Philipp von Weitershausen philipp at weitershausen.de
Thu Oct 2 14:56:12 EDT 2003


Garrett Smith wrote:
> Below are my proposed changes:
> 
> 1. Add a new helper function 'containedObject'
> 
>  def containedObject(object, parent, name=None):

+1

> The class Foo in case 1 would be as follows:
> 
>   class Foo:
>       def __init__(self):
>           self.bar = containedObject(Bar(), self, 'bar')
> 
> 2. Add a new helper function 'setContained':
> 
>  def setContained(parent, setf, getf, name, object):

I like the idea. However, I have the feeling the name of the function 
should somewhat reflect the fact that it's generating events. Also, 
returning the result of containedObject() sounds like a good idea to me.

> I agree with the decision to implement the container bookkeeping 
> directly in container classes rather than through adapters -- it's much 
> simpler and therefore less prone to error. However, I think the current 
> implementation is a bit too inflexible. These proposed changes are an 
> attempt to add enough flexibility without having to resort to adaptation.

I agree.

I too have a small wish for the post-parendgeddon world of Zope3. In two 
recent applications that I am porting over from ContextWrappers, one of 
them being the zopeproducts.xml.dom package, I have realized that I 
often need to express containment, or rather parenthood, however without 
the naming part.

For example, a DOM node usually has a parent but it doesn't have a 
specific name in that 'container' node. So, what I would like to see is 
basically a subset of that container machinery (let's call it "parenting 
machinery") or, rather, the container machinery being an extension of 
the parenting machinery. That way adaptors defined at the parenting 
level still work for objects at the container level.

Thoughts?

Philipp





More information about the Zope3-dev mailing list