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

Max M maxm@mxm.dk
Wed, 30 Apr 2003 21:40:46 +0200


Steve Alexander wrote:

> What about making relationships among pre-existing objects that were 
> not designed with relationships in mind? 


Exactly!

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.

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 ...


regards Max M