[Zope-CMF] Relating different objects to each other
Max M
maxm@mxm.dk
Sat, 12 Oct 2002 20:34:03 +0200
sean.upton@uniontrib.com wrote:
> Short term: use Max M's mxmRelation product (which is not CMF specific).
> For each type of relation, you will need to create a mxmRelation object in
> the root of your CMF site,
Just as a sidenote here on "best practice". I have found it usefull to
have an objectmanager, or a folder, called "relations" in which I put
all the relation objects.
relations/
student_class
student_teacher
student_subjects
etc ...
Also it makes it easier to delete all relations to an object when the
object is deleted or moved, by simply:
for relation in self.relations:
relation.delete(self)
And a few other things.
... cms stuff snipped ...
> Long term: I'm sure that eventually, need will dictate a more scalable
> relationship management tool in the CMF. See thread on this in the archives
> from a few days ago.
I don't think it is possible to make it much better in Zope than is done
by mxmRelations. The nessecary infrastructure simply isn't there in Zope 2.x
In Z3 there will be the objecthub, which will make a relations product
better and automate some of the things that has to be done manually now.
But I have added code to maintain relations during a move of an object
which is really very simple to use, and only adds a few extra lines to
objects using it.
currently mxmRelations is basically a dictionary of paths.
relation = {
'path/to/obj1':['path/to/obj2', 'path/to/obj3'],
'path/to/obj2':['path/to/obj1', 'path/to/obj3'],
'path/to/obj3':['path/to/obj1', 'path/to/obj2'],
}
By accident this is a so called "graph" as used in AI ;-)
The most obvious improvement of mxmRelations would be to convert this
dictionary into a OOBtree structure. This will happen when I get the
need, or when somebody sends me a patch ;-)
My guess is that it would be a *very* simple change! And would make the
product as scalable as the ZODB allows.
Currently I have some thousand objects in each relation and I don't have
performance problems. Put hundred of thousand of objects onto one and
you could get problems. I don't know, I haven't tried :-)
regards Max M
"Skeptic Effect" or the "Randi Effect"
When a skeptic is near, supernatural effects seem to disappear.