[Zope3-Users] Problem with containers

Rob Campbell rcampbell at pcwi.net
Fri Sep 15 11:39:43 EDT 2006

Martijn Pieters wrote:
> On 9/15/06, Rob Campbell <rcampbell at pcwi.net> wrote:
>> I just recently started trying out Zope 3.  My first test project is a
>> few containers that can contain other containers or an object.  They are
>> laid out as follows:
>> FosterRecord
>> -> FosterSource
>>      -> Foster
>>      -> FosterGroup
>>         -> Foster
>> A FosterRecord is the top level container and can contain a
>> FosterSource.  A FosterSource can contain a Foster object or a
>> FosterGroup.  And a FosterGroup can contain a Foster object.
> You cannot combine multiple contained or container constraints; you'll
> have to define a contained contstraint for the Foster implementation
> that includes both IFosterSource and IFosterGroup.

Ok, so it can't be done by implementing both IFosterSourceContained and 
IFosterGroupContained?  I am doing that currently with the following code:

class Foster(Contained):

   implements(IFoster, IFosterSourceContained, IFosterGroupContained)

Would I need to create a new IContained interface?  Maybe something like 

class IFosterSourceOrGroupContained(IContained):

   containers(IFosterSourceContainer, IFosterGroupContainer)

and then change Foster to this:

class Foster(IContained):

   implements(IFoster, IFosterSourceOrGroupContained)

Thank you for the help.

Rob Campbell

More information about the Zope3-users mailing list