[Zope-CMF] Relating different objects to each other

Jeffrey P Shell jeffrey@cuemedia.com
Fri, 11 Oct 2002 14:43:10 -0600


Relationships between objects in Zope is very hard, unless all paths 
stay the same forever.   The only time I made a 'related items' thing 
work by explicit linking was a situation where I had everything in the 
same folder and didn't have to deal with paths.  I was also using 
ZPatterns which has some decent object event trigger handling, so I 
could catch a deletion of one object and remove the link to it from 
another.  But it's not a scalable solution.

What you can do out of the box with the CMF is to make smart use of 
metadata and have the related items be a dynamic query based on certain 
criteria.  You could search on the Subject keywords, and have a big 
vocabulary of subjects.  The 'related items' list could be a list of 
the five most recent content items matching the same (or very similar) 
Subject list as the current item.

On Friday, October 11, 2002, at 02:04  PM, Phil Glaser wrote:

> Hi,
>
> I am building a site where my client would like to have a "related 
> items"
> feature. The idea would be that, for example, when you display a news 
> item,
> you would also display a list of other items, from the same or 
> different
> object type, that are related to it. So for the news item, the related 
> item
> list might include a document, an event, a link, etc., that are 
> thematically
> associated with that object.
>
> Is there a way to do this out of the box with CMF?
>
> If not, the way I was thinking of approaching this is as follows: 
> every type
> that can be related in this way would have a list property that 
> contains the
> ids of items to which it is related. The search catalog would index 
> this
> property. When you display the related items for an object, you would 
> do a
> catalog search against the object's id in the related items list 
> index. When
> you create the relationship between one item and another, you are 
> simply
> adding the item's id to the other item's list property.

Programmers use the word 'simply' too much!  :)  If object 
'/company/about' refers to '/news/earnings', and '/news/earnings' goes 
away - how do you catch that in Zope?  Answer - not easily.  If it's 
just a rename - from 'earnings' to '2002earnings', the link will go 
away in that situation too.  This is an artifact of many Zope 2 issues, 
particularly its lack of constant unique ID's that are separate from an 
object path, and lack of a rich event handling architecture that would 
let objects register interest in others so they can be notified of 
changes that affect the path - a rename, move, or delete.  Zope 3 
should at least solve the latter issue.

There are other solutions that have been proposed, like Ken Manheimer's 
Organization Objects, to help fill in the spaces between objects.  I 
myself have done an Associations and an Event tool, but neither of them 
are finished (nor have they even been tested extensively).

> If this is a sound approach, I'm wondering if the cleanest way of
> implementing it would be to implement the list property, and any 
> related
> methods, in the object hierarchy above the level of the different
> information types. Since the object hierarchy is not documented 
> anywhere,
> I'm not sure where the most logical place to do this modification 
> would be,
> and welcome any suggestions.
>
> Or, a completely different approach.