[Zope-dev] RFC: RelationAware class for relations betweenobjects

roche@upfrontsystems.co.za roche@upfrontsystems.co.za
Thu, 1 May 2003 09:21:47 +0200


* Max M <maxm@mxm.dk> [2003-04-30 21:42]:
> Steve Alexander wrote:
> 
> >What about making relationships among pre-existing objects that were 
> >not designed with relationships in mind? 
> 
> 
> Exactly!

I think Shane's API can cope with this - it will have to ;-)

> 
> Without thinking I send this to Zope-dev: But here it goes again:
> 
> If an object needs to be related to another object, there is no need for 
> any of the objects to know they are related. If all the relations are 
> external to the objects you can relate objects that are not programmed 
> to be related. Keeping all the relation code loosely coupled from the 
> objects.

Objects *do* need to know they are related or have some mechanism to infer
a relationship if:

    - they want to access and manipulate related objects as attributes.

    - a persistence framework needs to discover relationships

> Making the objects hold the responsibility for the relations means that 
> all objects has to take it into account. There is no reason for that. To 
> take a simplified example from Plone.
> 
> relations/
>   members_groups
> 
> Members/
> Groups/
> 
> In this case I can make the "members_groups" relationship manager take 
> care of the relations, and Members and Groups would not need to know 
> they can be related. I don't have to change the code in Members at all. 
> Thus leaving Plone as it is, while I can add group functionality.
> 
> maxm_groups = context.relations.member_groups.get(context.Members.maxm)
> 
> The other way around I would need to change the Member product, adding 
> group relations, and I can risk all hell breaking loose when Plone is 
> updated the next time.
> 
> I wonder if any of you guys reinventing relationships has even bothered 
> to try out the mxmRelations product? You are taking the long and winding 
> road to get to the same conclusions I did a year ago ...

As you know, I know mxmRelations well and am currently using it to store
relationships between objects in Zope 2. But mxmRelations only solves
part of the problem: storing and retrieving relationships between
objects. Additionally one needs a simple way to teach an object how to
compute relationships as attributes. This is not easy in Zope and
writing a method and ComputedAttribute for each relationship per class
is too much work. Given this, it excites me that there is so much talk
to do relationships at ZODB level.

For me there is a lot of overlap between the ideas about Relationships
in this discussion, mxmRelations and ObjectHub ie. a repository type
service for relationships. The significant differences are that any
API coming forth should make relationships discoverable on a object and
that it should not be Zope specific.

-- 
Roché Compaan
Upfront Systems                 http://www.upfrontsystems.co.za