[Zope-CMF] 'portal_metadata' tool in CVS
marc lindahl
marc@bowery.com
Sun, 06 May 2001 18:33:12 -0400
> From: Tres Seaver <tseaver@novacoxmail.com>
>
> I've patched it to accomplish a couple of goals:
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()
If those were public, the form could use them.
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.
Here is full_metadata_edit_form.dtml with changes:
<dtml-var standard_html_header>
<div class="Desktop">
<dtml-if message>
<p>&dtml-message;</p>
<hr>
</dtml-if>
<div class="Metadata">
<h2>Resource Metadata </h2>
<dtml-let effectiveString="effective_date and effective_date.ISO() or
'None'"
expirationString="expiration_date and expiration_date.ISO() or
'None'"
>
<form action="metadata_edit" method="post">
<table class="FormLayout">
<tr valign="top">
<th align="right"> Identifier
</th>
<td colspan="3"> <dtml-var Identifier>
</td>
</tr>
<tr valign="top">
<th align="right"> Title
</th>
<td colspan="3">
<input type="text"
name="title"
value="&dtml-Title;"
size="65">
</td>
</tr>
<tr valign="top">
<th align="right"> Description
</th>
<td colspan="3">
<textarea name="description:text" rows="5"
cols="65">&dtml-Description;</textarea>
</td>
</tr>
<tr valign="top">
<th align="right"> Subject
</th>
<dtml-comment> Support portal_metadata limiting of subjects
</dtml-comment>
<td>
<dtml-if "portal_metadata and
portal_metadata.listAllowedSubjects( this() )">
<dtml-let allowed="portal_metadata.listAllowedSubjects( this() )"
raw_size="_.len( allowed )"
min_size="raw_size < 5 and 5 or raw_size+1"
max_size="min_size > 10 and 10 or min_size"
size=max_size
subject=Subject
>
<select name="subject:list" multiple size="&dtml-size;">
<dtml-in allowed>
<dtml-let item=sequence-item
sel="subject and item in subject and 'selected' or ''"
>
<option value=&dtml-sequence-item; &dtml-sel;>
&dtml-item;
</option>
</dtml-let>
</dtml-in>
<option value=""></option>
</select>
</dtml-let>
<dtml-else>
<textarea name="subject:lines" rows="5"
cols="30"><dtml-in Subject><dtml-var sequence-item>
</dtml-in></textarea>
</dtml-if portal_metadata>
</td>
<th align="right"> Contributors
</th>
<td>
<textarea name="contributors:lines" rows="5"
cols="30"><dtml-in Contributors><dtml-var sequence-item>
</dtml-in></textarea>
</td>
</tr>
<tr valign="top">
<th align="right"> Creation Date
</th>
<td> <dtml-var CreationDate>
</td>
<th align="right"> Last Modified Date
</th>
<td> <dtml-var ModificationDate>
</td>
</tr>
<tr valign="top">
<th align="right"> Effective Date
</th>
<td> <input type="text" name="effective_date"
value="&dtml-effectiveString;">
</td>
<th align="right"> Expiration Date
</th>
<td> <input type="text" name="expiration_date"
value="&dtml-expirationString;">
</td>
</tr>
<tr valign="top">
<th align="right"> Format
</th>
<dtml-comment> Support portal_metadata limiting of Format
</dtml-comment>
<td>
<dtml-if "portal_metadata and
portal_metadata.listAllowedFormats( this() )">
<dtml-let allowed="portal_metadata.listAllowedFormats( this() )"
raw_size="_.len( allowed )"
min_size="raw_size < 1 and 1 or raw_size+1"
max_size="min_size > 10 and 10 or min_size"
size=max_size
thing=Format
>
<select name="format:list" size="&dtml-size;">
<dtml-in allowed>
<dtml-let item=sequence-item
sel="thing and item in thing and 'selected' or ''"
>
<option value=&dtml-sequence-item; &dtml-sel;>
&dtml-item;
</option>
</dtml-let item>
</dtml-in allowed>
<option value=""></option>
</select>
</dtml-let allowed>
<dtml-else>
<input type="text" name="format" value="&dtml-Format;">
</dtml-if portal_metadata>
</td>
</tr>
<tr valign="top">
<th align="right"> Language
</th>
<dtml-comment> Support portal_metadata limiting of Language
</dtml-comment>
<td>
<dtml-if "portal_metadata and
portal_metadata.listAllowedLanguages( this() )">
<dtml-let allowed="portal_metadata.listAllowedLanguages( this() )"
raw_size="_.len( allowed )"
min_size="raw_size < 5 and 5 or raw_size+1"
max_size="min_size > 10 and 10 or min_size"
size=max_size
thing=Subject
>
<select name="language:list" size="&dtml-size;">
<dtml-in allowed>
<dtml-let item=sequence-item
sel="thing and item in thing and 'selected' or ''"
>
<option value=&dtml-sequence-item; &dtml-sel;>
&dtml-item;
</option>
</dtml-let item>
</dtml-in allowed>
<option value=""></option>
</select>
</dtml-let allowed>
<dtml-comment> For this to work security has to be changed in
MetadataTool.py
<dtml-if "not portal.metadata.getElementSpec( 'Language'
).enforceVocabulary()">
<input type="text" name="language" value="&dtml-Language;">
</dtml-if>
</dtml-comment>
<dtml-comment> other stuff that could work with some security change:
portal.metadata.getElementSpec( 'Language' ).isRequired()
portal.metadata.getElementSpec( 'Language' ).supplyDefault()
portal.metadata.getElementSpec( 'Language' ).defaultValue()
</dtml-comment>
<dtml-else>
<input type="text" name="language" value="&dtml-Language;">
</dtml-if portal_metadata>
</td>
</tr>
<tr valign="top">
<th align="right"> Rights
</th>
<dtml-comment> Support portal_metadata limiting of Rights
</dtml-comment>
<td>
<dtml-if "portal_metadata and
portal_metadata.listAllowedRights( this() )">
<dtml-let allowed="portal_metadata.listAllowedRights( this() )"
raw_size="_.len( allowed )"
min_size="raw_size < 1 and 1 or raw_size+1"
max_size="min_size > 10 and 10 or min_size"
size=max_size
thing=Rights
>
<select name="format:list" size="&dtml-size;">
<dtml-in allowed>
<dtml-let item=sequence-item
sel="thing and item in thing and 'selected' or ''"
>
<option value=&dtml-sequence-item; &dtml-sel;>
&dtml-item;
</option>
</dtml-let item>
</dtml-in allowed>
<option value=""></option>
</select>
</dtml-let allowed>
<dtml-else>
<input type="text" name="rights" value="&dtml-Rights;">
</dtml-if portal_metadata>
</td>
</tr>
<tr valign="top">
<td> <br> </td>
<td>
<input type="submit" value=" Change ">
</td>
</tr>
</table>
</form>
</dtml-let>
</div>
</div>
<dtml-var standard_html_footer>