[ZODB-Dev] Re: [Zope3-dev] PROPOSAL: ZODB Relationships

Shane Hathaway shane at zope.com
Sun May 11 00:02:20 EDT 2003


This is interesting stuff, but I have a few questions.

On 05/09/2003 06:47 PM, Phillip J. Eby wrote:
> teacher = AssociationEnd(multiplicity=(1,1))
> courses = AssociationEnd(multiplicity=(1,None))  # if we use None for 
> unbounded
> Teaches = Association(teacher, courses)

The code that stores the links in the association needs a way to find 
out the name of the association, and this code doesn't provide a way. 
Nor are the names of the ends provided.  The variable names 'teacher', 
'courses', and 'Teaches' are all local and not exposed.

It would be nice to fix that and reduce the verbosity at the same time. 
  This is a common "one to many" association, and there ought to be a 
simpler way to express that.  (A teacher can be assigned to zero 
courses, so the multiplicity of the "courses" end should allow zero, 
shouldn't it?  And a course might lack a teacher.)

> teaches.add(aTeacher,aCourse)
> 
> aTeacher = Teaches.teacher.get(aCourse)
> hisCourses = Teaches.courses.get(theTeacher)

It surprises me that the ends would be available as attributes of the 
association with attribute names matching the names of the ends.  Is 
that the way MOF sees it?

> class Teacher:
>     courses = Reference(Teaches.course)
> 
> class Course:
>     teacher = Reference(Teaches.teacher)

It occurs to me that neither the proposal nor this example provide a way 
to tell Python the type exposed by the descriptors.  Teacher.courses is 
a sequence (or perhaps a set) of Courses, while Course.teacher is a 
Teacher.  Do we infer that from the multiplicity?  Hmm.

This is the first time I've heard of MOF.  Who is using it?  What 
problems does it solve better than UML?  UML is much more familiar to 
developers.  When you suggested "association", I opened the UML book I 
have on my desk and found all the terms I've been looking for.

We left out metadata from the proposal so we could get the proposal out 
there.  Roche and I were hoping to put metadata into a future version of 
the proposal.  However, MOF seems to deny the possibility of attaching 
metadata to individual links.  There are no association classes and only 
binary associations are allowed.  Maybe I misunderstood MOF, or maybe 
link metadata isn't important.

Shane




More information about the ZODB-Dev mailing list