[Zope] 'selection' and 'multiple selection' property types
Martijn Pieters
mj@antraciet.nl
Wed, 07 Jul 1999 16:32:08 +0200
At 20:48 05/07/99 , Alex Rice wrote:
>Is there an example anywhere of how to use these? I am looking in
>ZPublisher/Converters.py (2.0a3) and they are not defined there. Are
>these property types not implemented yet?
They are, for displaying a list as a SELECT field. It is very limited, you
can only use it for one field per propertysheet, but here goes:
If you have a tokens or lines property, lets call it 'colours_list', you
can display a SELECT list on your propertysheet by defining a property
called 'select_variable', type string, set to 'colours_list', and a
variable named, lets say, 'colours', type selection or multiple selection.
If you choose type 'selection', 'colours' will one value out of the
'colours_list' list, which the user of the propertysheet can select from a
drop-down box.
If you choose type 'multiple selection', 'colours' will hold a list of 0 or
more values from the 'colours_list' list, which the user can select from
the scrolling list. The height of the listbox is either 7 or the number of
elements in 'colour_list', whichever is the smallest.
Personally, I'd like it to be more flexible on what list property is being
used to fill the drop-down list or listbox. Maybe, for a (multiple)
selection property named xxx, you should define a text property named
xxx_select_variable. This way you can have more than one (multiple)
selection property on any given propertysheet.
Example:
// The following four vars could be defined on a seperate
// propertysheet without a public view
colours_list (tokens) = "red yellow green blue"
colours_select_variable (string) = "colours_list"
sizes_list (tokens) = "smallest small smaller medium larger large largest"
sizes_select_variable (string) = "sizes_list"
// These property defined on a public propertysheet
colours (selection) = "red" (populated from 'colours_list')
sizes (selection) = "medium" (populated from 'sizes_list').
Patch to properties.dtml to support this:
*** properties.dtml~ Wed Jul 7 15:37:41 1999
--- properties.dtml Wed Jul 7 16:18:08 1999
***************
*** 64,72 ****
"getProperty(id)"--><!--#var sequence-item--><!--#if
sequence-end--><!--#else--><!--#var
"'\n'"--><!--#/if--><!--#endin--></textarea>
<!--#elif "type=='selection'"-->
! <!--#if "_.has_key(select_variable)"-->
<select name="<!--#var id-->">
! <!--#in "_[select_variable]"-->
<option
<!--#if
"_['sequence-item']==getProperty(id)"-->SELECTED<!--#/if-->
><!--#var sequence-item--></option>
--- 64,72 ----
"getProperty(id)"--><!--#var sequence-item--><!--#if
sequence-end--><!--#else--><!--#var
"'\n'"--><!--#/if--><!--#endin--></textarea>
<!--#elif "type=='selection'"-->
! <!--#if "_.has_key(_[id + '_select_variable'])"-->
<select name="<!--#var id-->">
! <!--#in "_[_[id + '_select_variable']]"-->
<option
<!--#if
"_['sequence-item']==getProperty(id)"-->SELECTED<!--#/if-->
><!--#var sequence-item--></option>
***************
*** 73,90 ****
<!--#/in-->
</select>
<!--#else-->
! No value for <!--#var select_variable-->
<!--#/if-->
<!--#elif "type=='multiple selection'"-->
! <!--#if select_variable-->
<select name="<!--#var id-->:list" multiple
! size="<!--#var "_.min(7, _.len(_[select_variable]))"-->">
! <!--#in "_[select_variable]"-->
<option<!--#if
"_['sequence-item'] in getProperty(id)"--> SELECTED<!--#endif
-->><!--#var sequence-item--></option>
<!--#/in-->
</select>
<!--#/if-->
<!--#else-->
<em>Unknown property type</em>
--- 73,92 ----
<!--#/in-->
</select>
<!--#else-->
! No value for <!--#var "_[id + 'select_variable']"-->
<!--#/if-->
<!--#elif "type=='multiple selection'"-->
! <!--#if "_.has_key(_[id + '_select_variable'])"-->
<select name="<!--#var id-->:list" multiple
! size="<!--#var "_.min(7, _.len(_[_[id + '_select_variable']]))"-->">
! <!--#in "_[_[id + '_select_variable']]"-->
<option<!--#if
"_['sequence-item'] in getProperty(id)"--> SELECTED<!--#endif
-->><!--#var sequence-item--></option>
<!--#/in-->
</select>
+ <!--#else-->
+ No value for <!--#var "_[id + 'select_variable']"-->
<!--#/if-->
<!--#else-->
<em>Unknown property type</em>
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------