[Zope] Pointer-to-Object Properties

Otto Hammersmith otto@ipass.net
Tue, 02 Nov 1999 12:23:41 -0500


You got me thinking... that's a good thing, right? :)

Brian Lloyd wrote:
[snip] 
> I'd like to jump in and play devil's advocate for a moment. Note
> that this is not to necessarily refute the idea of pointer-to-obj
> properties, but more to start brainstorming and to help me get a
> better idea of the core problem here...
> 
> Historically (or hysterically, as Jim would say) properties have
> had some basic traits that distinguish them from "subobjects":
> 
>   o They are generally "simple named values" of simple types.
> 
>   o Being simple types, they have either no or very limited behavior.
> 
>   o They have somewhat less of a sense of "identity" than full
>     Zope objects.
> 
>   o They are not protected individually by the security machinery.
> 
> So to summarize, properties were really designed to be supporting
> players rather than lead actors on the Zope stage - they should
> be thought of as metadata about an object more than as objects
> themselves in most cases.

You've left off one *really* useful practical application of (Z Class)
properties. They're *guaranteed* to be there, at least, with their
default values. The lack of this ability with full-fledged objects isn't
quite the same domain as the book/author problem, so I digress. :)
(Plus, there are work arounds that may not be pretty, but they work.)
 
[snip]
> Rather than do a lot of work extending the meaning and
> capabilities of properties, it seems to me that this could
> be handled if we had some sort of "reference" object. 

[snip]

You've just hit the nail on the head.

The perfect solution to provide the feature you want here is XLink,
http://www.w3.org/TR/1998/WD-xlink-19980303. This spec describes how to
use XML to express any kind of relationship between any number of
objects. They can be embedded in one of the objects (inline), like HTML
<A> tag, or they can be "out of line" and point to several objects.

It's easy to envision a Z Class based on XML Document that is simply an
XLink.  Zope with Z Catalog gives server side framework to make XLink
work until all browsers support it. Simply create a Z Catalog that only
indexes the links and their properties, suddenly it's easy (and fast!)
to find out things like "who points to me?"

In terms of your example, 'theBook.getAuthors()' would query the link
catalog for links that referenced theBook with the 'role' of 'author'
(*).  The XLink implementation details wouldn't matter...
 o the link could be coming from an Author object pointing to this book
 o from an out of line link that associated the two
 0 or even an inline link at the book's end

(*) See the spec on more information on roles. Basically each locator
can be associated with a role... which is not defined by the XLink
standard but by standards based on XLink, i.e., everyone has to agree
what a role of 'author' means.

Take the more interesting example of annotating a document.  Each
document could provide a "Annotate" link at the bottom (along with
"Printable Page" :) that allows the browser to comment on the document. 
When I click on that link a new XLink is created in my "home" directory
and I add my comment.  It automatically gets cataloged in the link
catalog.  Now that there is an annotation, a "View Annotations" link
appears and everyone can click on that to see the annotation.  That
document is simply generated by displaying all the links of role
'annotation' in the link catalog.

XLink (really XPointer) provides a way to link to specific parts of a
document, so ideally an annotation could be attached to a specific
paragraph. Then when the document is rendered, there is an HTML <A> tag
at the appropriate place to display the comment. It would even be
possible to show the annotation as a sidebar at the appropriate place.

(Note: the link itself contains the body of the annotation... see the
Annotated XML Standard, http://www.xml.com/pub/axml/axmlintro.html, for
another implementation of annotation using XLink.)

The one drawback is that (right now) I don't think Z Catalogs can index
parts of objects. This limits the usefulness of inline links in XML
documents.  Are there any technical limitations to the design (of Z
Catalog or XML Document) that would prevent this from being possible?

> Well, I've rambled on long enough - let me know if any of this
> has the ring of truth to you or if you think I'm totally missing
> the point...

I think I've rambled on enough, too. :)

Please tell me if this makes any sense to someone other than me. It may
be necessary to read (or at least scan) the XLink (and possibly
XPointer)  standards to grok what I'm thinking.

			-Otto.