[Zope3-dev] annotations/dc and component definitions

Garrett Smith garrett@mojave-corp.com
Tue, 22 Apr 2003 15:58:08 -0500


I'm a bit confused about the use of annotations and component
"definitions".

As an example, assume I want to create a system to manage a library of
books. I create an interface IBook:

  class IBook(Interface):
    title =3D TextLine(...)
    author =3D TextLine(...)
    publishDate =3D DateTime(...)
    ...

Clearly there's overlap in IBook with the DC 'title' annotation. (In
fact, there is massive overlap as book cataloging is a primary DC
application.)

My questions:

 - I've noticed that several (most?) content types in Zope 3 use
IAttributeAnnotatable to signal that they support annotation via object
attributes. Should an interface omit a property (e.g. title,
description, etc.) under the assumption that it will be handled via
"metadata"? (A good example of this is the NewsSite INewsItem interface
-- it only defines teaser and body, letting DC annotations handle the
rest.)

 - If I really want my interface to define 'title' (for clarity, data
control/ownership, etc.), what is the recommended approach for
supporting DC metadata? My inclination would be to create an
IAnnotations adapter that looked for specific annotation keys (e.g.
"zope.app.dublincore.ZopeDublinCore.title") and redirected to the
component properties (e.g. get/setTitle).

 - Is there a concept of read-only annotations? The scenario I'm
thinking of is when metadata is derived from other component properties.
E.g. the metadata 'title' for a Person might be a function of the
person's salutation, first and last names, and suffix. In such a case,
title would not be writable, but used to represent the person in a list,
etc.

I suppose these questions are getting at the intended use of
annotations. Getting more to the point:

 - Should annotations be used to implement component properties or be
limited to "attaching" data to a component (as the term 'annotate'
implies)? What are the guidelines here?

 - What happens when component properties and annotations overlap or
collide? (I see collision being when a metadata value "is the same as" a
component property or when a metadata value "is a function of" one or
more component properties.)

- Garrett Smith