[Zope] beginner's question: references

Michael Bernstein webmaven@lvcm.com
Fri, 17 Mar 2000 08:52:42 +0000


Rik Hoekstra wrote:
> 
> [RH]Michael,
> 
> What you seem to be descibing is some sort of an internal Zope 'link base'
> as they exist for may hypertext systems (but zopish). This would be very
> useful.
> I do have some doubts about your desciption, however:
> 
> - would the generic relationships (meta-type<->meta-type) you describe be
> the best way to go and whether they would turn out to be very useful.

Well, this gives you the ability to create, for example, 'Car' and
'Bicycle' objects, and designate them both as meta type 'vehicle', then
create an 'Owner' relationship between 'vehicle's and 'Person's. A
trivial example, to be sure.

I suppose the relationship objects could be 'instrumented' to allow
other types of filtering criteria. Whatever the criteria though, the
possible objects need to be presented through a 'relationships' form
within the ZClass instance.

> You
> also do not mention one-to-one relationships; I'm sure this is not on
> purpose, but this could be implemented quite simply by a specific python
> product.

You're right, one-to-one relationships should be implemented as well,
but as you noted, this proposal is not as critical to implementing
one-to-one relationships as it is for many-to-many.

> - I also wonder whether much of what you describe cannot also be achieved in
> other ways, mainly through using the Catalog (as you indicated yourself). If
> I may speculate a bit more on this point: what you want may be a specialized
> folder index method that uses a mix of its own objectValues and Catalog
> obtained objectvalues for its contents. 

That's pretty close. My proposal actually has two levels of indirection:
first the relationship objects that are relevant to the ZClass are
obtained from a ZCatalog like object (the relationship folder in the
control panel), and then those relationship objects (themselves
ZCatalog-like) are queried to obtain the objects that the ZClass
instance is associated with. Then you should be able to access these
objects' properties and contents as if they were contained within the
current object's relationship:

<dtml-in Author>
<dtml-var name>
</dtml-in>

By doing it this way, you can add relationship types between you classes
as your application grows in complexity without having to re-instantiate
all your objects. All you would have to change would be the add/edit
methods in the ZClass, and whatever viewing methods that you want to
expose the new information (other than the relationships tab in the
management intrface).

> If you wanted to use symlink type
> relations, this may be done by using properties (this is more or less
> generic) or by using the values of a 'link base' type of object (see above).
> This last would be very specific: pointing to specific objects.

Neither approach would give me the ability to refer to linked to objects
as if they were sub-objects. This is critical for the simplicity of the
DTML to access the associated objects' contents and properties. In
short, I want a pseudo sub-object that acts as a proxy for the real
object, not a symlink I can follow or resolve to access. The end result
is much the same, but the semantics are radically simpler with my
proposal. Note: associated objects should NOT appear within the
'Contents' tab.

> - The idea of relationship aware is nice, but the drawback is that it can
> only be true for derived ZClasses, and not all zope objects are Zclasses.

First, relationship_aware is optional; all it's absence means is that
the object is not aware of it's outgoing relationships. Other
relationship_aware objects could refer to it with no problem. Second,
if, for example,  you want a relationship_aware Folder, just subclass
Folder and relationship_aware in a new ZCLass.

> - In ZDP list many of these subjects have been in question for some time
> now. You may want to have a look at the list archives of last month for many
> of the discussions and of course the implementation of ZDP Tools by Maik
> Roeder (available somewhere from his member page:
> http://www.zope.org/Members/roeder)

I'll check it out, thanks.

Michael Bernstein.