[Zope3-Users] "has a" relationships

Gary Poster gary at zope.com
Mon May 8 15:53:35 EDT 2006


On May 4, 2006, at 5:16 PM, Jachin Rupe wrote:

> hi there
>
> I have another "zope theory" question.  I am working on designing a  
> application in zope.  I've been looking at a lot of examples and I  
> am wondering how people are implementing different types of  
> relationships between different persistent objects.

Depends on the relationship.

>
> For instance I am going to be doing a lot with addresses.   
> Naturally it would be nice to have persistent Address class.  Then  
> I would say that a Person has an Address and a Company has an Address.
>
> My two different ideas are as follows:
>
> 1.  Make Person and and Company containers that can each contain an  
> Address.  I don't really like this idea because it seems like  
> container objects are for things like folders.  This could be the  
> best way though and I'm just not zoppie enough yet.
>
> 2.  Add an Object for the Address to the schema for IPerson and  
> ICompany (assuming I only need one address) or a List / Dict (if I  
> want more than one address for each person or company).  I like  
> this idea better but I have yet to see any examples where someone  
> does that which is making me a little nervous.   Among other things  
> I'd like to be able to see what happens when "addform"s and  
> "editform"s get generated for things like this or at least be  
> assured that's the way it is supposed to work.

This should work, and it seems like the right way to model this  
particular kind of relationship.

If you were to want to reuse address objects for multiple people then  
you might need some different choices (of which there are many  
approaches and implementations).

Gary


More information about the Zope3-users mailing list