Commit 3afce24c authored by 's avatar

Commited work from Evans property name/type changing branch. The only

user-visible change for now is that property types are now shown for
each property. The actual name/type changing code is pretty minimal,
so it has been committed to the trunk but is not yet exposed. We'd
like to get some community input on the UI to make sure its what we
want (and get the documentation updated) before exposing it.
parent 6f68618d
......@@ -84,7 +84,7 @@
##############################################################################
"""Property management"""
__version__='$Revision: 1.23 $'[11:-2]
__version__='$Revision: 1.24 $'[11:-2]
import ExtensionClass, Globals
import ZDOM
......@@ -169,6 +169,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
manage_propertiesForm=HTMLFile('properties', globals(),
property_extensible_schema__=1)
manage_propertyTypeForm=HTMLFile('propertyType', globals())
title=''
_properties=({'id':'title', 'type': 'string', 'mode':'w'},)
......@@ -180,6 +181,8 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
'manage_delProperties',
'manage_changeProperties',
'manage_propertiesForm',
'manage_propertyTypeForm',
'manage_changePropertyTypes',
)),
('Access contents information',
('hasProperty', 'propertyIds', 'propertyValues','propertyItems',''),
......@@ -337,6 +340,26 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
message='Your changes have been saved',
action ='manage_propertiesForm')
# Note - this is experimental, pending some community input.
def manage_changePropertyTypes(self, old_ids, props, REQUEST=None):
"""Replace one set of properties with another
Delete all properties that have ids in old_ids, then add a
property for each item in props. Each item has a new_id,
new_value, and new_type. The type of new_value should match
new_type.
"""
err = self.manage_delProperties(old_ids)
if err:
if REQUEST is not None:
return err
return
for prop in props:
self._setProperty(prop.new_id, prop.new_value, prop.new_type)
if REQUEST is not None:
return self.manage_propertiesForm(self, REQUEST)
def manage_delProperties(self, ids=None, REQUEST=None):
"""Delete one or more properties specified by 'ids'."""
......
......@@ -23,7 +23,7 @@ The following properties are defined for this item.
<dtml-if property_extensible_schema__>
To <a href="#addpropform">
add a new property</a>, enter a name, type and value for the new property
and click the &quot;Add&quot; button.
and click the &quot;Add&quot; button.
</dtml-if>
To change property values, edit the
values and click "Save Changes".
......@@ -45,7 +45,7 @@ values and click "Save Changes".
<dtml-if "type == 'int'">
<input type="text" name="<dtml-var id>:<dtml-var type>" size="35"
value="<dtml-if "hasProperty(id)"><dtml-var
"'%d' % getProperty(id)" html_quote></dtml-if>">
"'%s' % getProperty(id)" html_quote></dtml-if>">
<dtml-elif "type == 'long'">
<input type="text" name="<dtml-var id>:<dtml-var type>" size="35"
value="<dtml-if "hasProperty(id)"><dtml-var
......@@ -103,18 +103,29 @@ values and click "Save Changes".
</table>
</dtml-if>
</td>
<td align="left">
-- &dtml-type;
</td>
</tr>
</dtml-in>
<tr>
<td align="left" valign="top" width="16">
</td>
<td align="left" valign="top" width="16">
</td>
<td colspan="2">&nbsp;</td>
<td align="left" valign="top">
<input type="submit" name="manage_editProperties:method"
value="Save Changes">
<dtml-if property_extensible_schema__>
<input type="submit" name="manage_delProperties:method" value="Delete">
</td>
<td>
<dtml-comment>
This needs some community review before exposing it officially.
<input type="submit" name="manage_propertyTypeForm:method" value="Change Names/Types">
</dtml-comment>
</td>
<dtml-else>
<td>&nbsp;</td>
</dtml-if>
</td>
</tr>
</table>
......@@ -142,7 +153,7 @@ of strings from which the selection(s) can be chosen.
</p>
<table>
<tr>
<th align="left" valign="top">Id</th>
<th align="left" valign="top">Name</th>
<td align="left" valign="top"><input type="text" name="id" size="20"></td>
<th align="left" valign="top">Type</th>
<td align="left" valign="top">
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>Change Property Types</title>
</head>
<body bgcolor="#FFFFFF" link="#000099" vlink="#555555">
<dtml-var manage_tabs>
<dtml-if Principia-Version>
<p>
<em>You are currently working in version <dtml-var Principia-Version></em>
</p>
</dtml-if Principia-Version>
<dtml-unless props>
<dtml-if ids>
<dtml-call expr="REQUEST.set('props', [])">
<dtml-call expr="REQUEST.set('old_ids', ids)">
<dtml-in propertyMap mapping>
<dtml-if expr="id in ids">
<dtml-call expr="props.append({'new_id': propertyLabel(id),
'new_type': type, 'new_value': getProperty(id),
'was_seq': type in ('tokens', 'lines', 'multiple selection')})">
</dtml-if>
</dtml-in>
</dtml-if>
</dtml-unless>
<form action="<dtml-var URL1>" method="POST">
<dtml-if old_ids>
<p>
To change property names and values, edit them and click
&quot;Save Changes&quot;. To edit properties using their new type,
select the new types and click &quot;Edit with new Types&quot;
</p>
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><b>Property Name</b></td>
<td><b>Value</b></td>
<td><b>New Type</b></td>
</tr>
<dtml-in old_ids>
<input type="hidden" name="old_ids:list" value="&dtml-sequence-item;">
</dtml-in>
<dtml-in props mapping>
<dtml-if expr="new_type in ('tokens', 'lines', 'multiple selection')">
<input type="hidden" name="props.was_seq:records" value="1">
<dtml-else>
<input type="hidden" name="props.was_seq:records" value="">
</dtml-if>
<dtml-let value_name="'props.new_value:' + {'multiple selection': 'list',
'selection': 'string'}.get(new_type, new_type) + ':records'">
<tr>
<td align="left" valign="top">
<input type="text" name="props.new_id:records" value="&dtml-new_id;">
</td>
<td align="left" valign="top">
<dtml-if expr="new_type in ('int', 'long', 'float', 'date', 'string', 'tokens')">
<input type="text" name="&dtml-value_name;" size="35"
<dtml-if was_seq>
value="<dtml-in new_value>&dtml-sequence-item; </dtml-in>"
<dtml-elif expr="new_type=='long'">
value="<dtml-var expr="_.str(getProperty(id))[:-1]" html_quote>"
<dtml-else>
value="&dtml-new_value;"
</dtml-if>>
<dtml-elif "new_type=='boolean'">
<input type="checkbox" name="&dtml-value_name;" size="35"
<dtml-if new_value>CHECKED</dtml-if>>
<dtml-elif "new_type in ('text', 'lines')">
<textarea name="&dtml-value_name;" rows="6" cols="35"><dtml-if was_seq><dtml-in
new_value>&dtml-sequence-item;<dtml-unless
sequence-end><dtml-var expr="'\n'"></dtml-unless></dtml-in><dtml-else>&dtml-new_value;</dtml-if></textarea>
<dtml-elif "new_type=='selection'">
<dtml-if "_.has_key(select_variable)">
<select name="&dtml-value_name;">
<dtml-in "_[select_variable]">
<option
<dtml-if "_['sequence-item']==new_value">SELECTED</dtml-if>
>&dtml-sequence-item;</option>
</dtml-in>
</select>
<dtml-else>
No value for <dtml-var select_variable>.
</dtml-if>
<dtml-elif "new_type=='multiple selection'">
<dtml-if "_.has_key(select_variable)">
<select name="&dtml-value_name;" multiple
size="<dtml-var "_.min(7, _.len(_[select_variable]))">">
<dtml-in "_[select_variable]">
<option<dtml-if
"_['sequence-item'] in new_value"> SELECTED</dtml-if
>><dtml-var sequence-item html_quote></option>
</dtml-in>
</select>
<dtml-else>
No value for <dtml-var select_variable>.
</dtml-if>
<dtml-else>
<em>Unknown property type</em>
</dtml-if>
</td>
<td>
<select name="props.new_type:records">
<dtml-in expr="('boolean', 'date', 'float', 'int', 'lines', 'long', 'string'
, 'text', 'tokens', 'selection', 'multiple selection')">
<dtml-let SELECTED="('', 'SELECTED')[new_type==_['sequence-item']]">
<option &dtml-SELECTED;>&dtml-sequence-item;</option>
</dtml-let>
</dtml-in>
</select>
</dtml-let>
</td>
</tr>
</dtml-in>
<tr>
<td align="left" valign="top" width="16">
</td>
<td align="left" valign="top" colspan="2">
<input type="submit" name="manage_changePropertyTypes:method"
value="Save Changes">
<input type="submit" name="manage_propertyTypeForm:method"
value="Edit with new Types">
</td>
</tr>
</table>
<dtml-else>
<p>
No properties were selected for this item.
</p>
</dtml-if>
</form>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment