[Zope-CMF] 'portal_metadata' tool in CVS

Tres Seaver tseaver@digicool.com
Mon, 7 May 2001 08:08:50 -0400 (EDT)


On Sun, 6 May 2001, marc lindahl wrote:

> OK, I applied the patches to full_metadata_edit_form.dtml,
> expanding to include all the dublincore types that support
> vocabulary limitation.  I also put checks in there so that if
> the portal_metadata tool isn't installed, or the vocabulary is
> empty, that the old text inputs are there instead of the (empty
> or nonexistent) list.  I also put an empty pick on lists where
> appropriate, so you can 'reset' that choice to nothing.  I
> don't think it could be done in the vocabulary list in the
> portal_metadata tool.
> 
> I note in one section, in the comments, that there is more that
> could be done to expose the porta_metadata interface to the
> user, but it seems like the methods needed are protected.
> Specifically:
> 
>        portal.metadata.getElementSpec( 'Language' ).isRequired()
>        portal.metadata.getElementSpec( 'Language' ).supplyDefault()
>        portal.metadata.getElementSpec( 'Language' ).defaultValue()

First, you want to be invoking it as 'portal_metadata';  I don't
know how the other spelling is working at all for you.

> If those were public, the form could use them.

These three methods are intended to be called by the tool's own
'setInitialMetadata' and 'validateMetadata' methods;  I don't
think the form needs to call them.  It does need to be able to
ask whether the vocabulary is enforced, though:  imagine a site
which provides "suggested" vocabulary, but allows members to
enter other values (which might then eventually become part of
the "suggested" vocabulary).

I think the spelling here would be, as you suggest, to remove the
"hardcoded" methods from the interface ('listAllowedSubjects',
'listAllowedFormats', etc.) and instead expose 'getElementSpec',
protecting the spec's query methods with the 'View' permission.

> Though, come to think of it, defaultValue and supplyDefault
> probably only need to be done when a dublinCore object is
> created...
> 
> You can see that the code is so regular, it could probably be
> made into a macro or a method.

Right, I would probably add another "snippet" skin method which
generates the selection widget and text field, given the DC
element name;  call it 'vocabulary_widgets' or some such  (note
as well that only the Subject metadata is "multi-valued" by
default).
 
Tres.
-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org