Shane Hathaway wrote:
I don't know about the others participating in this thread, but I'm reaching quite different conclusions than you did. For example:
- The solution should not require Zope.
It is implemented as a Zope product, but the base class that implements the relationships is actually pure Python. The latest version is based on an OOBTree to handle the relations.
- It should not be necessary to visit the management interface to set up relationships.
No.
- Developers should have the *option* of using relationships directly in their classes, with a Pythonic API.
I think that should be working on top a general relationship service.
I listed other requirements this morning, and as far as I can tell, few are fulfilled by mxmRelations. On the other hand, maybe I misunderstand mxmRelations. Does it fulfill the requirements I listed? I'm sure there's nothing wrong with mxmRelations, but it seems like we're targetting different audiences.
Let me say that I am not married to mxmRelations, and I am not trying to push it as a solution. But I think it has a sound model for relationships. One that is very general and expandable. Here is a not even half baked pseudo example on how it could be implemented. Which uses the same idea as mxmRelations: class ManyToMany: # simillar to a mxmRelations class "A many to many Relationships, it can also hold meta data attrs" def __init__(self, name): self.name = name self.__relationship_graph = {} def relate(self, obj1, obj2): "relates 2 objects" def unrelate(self, obj1, obj2): "unrelates 2 objects" def del(self, obj): "Delete all relations to and from obj" def get(self, obj): "returns all relations to object" class RelationshipsManager: "Folder-like class to hold Relationships instances" def addRelationsships(self, name, relationsshipsInstance): "Adds a Relationships" def getRelationsships(self, name): "retuns a Relationships by name" def delRelationsships(self, name): "Delete a relationships" # perhaps a method on ZODB to return the RelationshipsManager ? rm = ZODB().getRelationshipsManager() rm.addRelationsships('members_groups', ManyToMany('members_groups')) r = rm.getRelationsships('members_groups') r.relate(someNewMember, someGroup) groups = r.get(someMember) >>> [someGroup]