[Zope] Re: Zclasses + 'selection' and 'multiple selection' property types
Alex Rice
alrice@swcp.com
Fri, 16 Jul 1999 15:52:52 -0600 (MDT)
On Wed, 07 Jul 1999 16:32:08 +0200,
Martijn Pieters <mj@antraciet.nl> said:
Martijn> If you have a tokens or lines property, lets call it
Martijn> 'colours_list', you can display a SELECT list on your
Martijn> propertysheet by defining a property called 'select_variable',
Martijn> type string, set to 'colours_list', and a variable named, lets
Martijn> say, 'colours', type selection or multiple selection.
Martijn> If you choose type 'selection', 'colours' will one value out of
Martijn> the 'colours_list' list, which the user of the propertysheet
Martijn> can select from a drop-down box.
Martijn> If you choose type 'multiple selection', 'colours' will hold a
Martijn> list of 0 or more values from the 'colours_list' list, which
Martijn> the user can select from the scrolling list. The height of the
Martijn> listbox is either 7 or the number of elements in 'colour_list',
Martijn> whichever is the smallest.
What do you enter for the initial value when creating a property of
'multiple selection' type?
Martijn> Personally, I'd like it to be more flexible on what list
Martijn> property is being used to fill the drop-down list or
Martijn> listbox. Maybe, for a (multiple) selection property named xxx,
Martijn> you should define a text property named
Martijn> xxx_select_variable. This way you can have more than one
Martijn> (multiple) selection property on any given propertysheet.
I definitely vote for something like this being included in Zope-- most
non-trivial ZClasses will likely need more than one selection property!
Martijn> Patch to properties.dtml to support this:
Not sure why the patch would not patch, but after you mailed me your
properties.dtml, it became obvious your approach. This works perfectly
for normal objects (like DTML Docs) However, this *doesn't* work with
ZClasses, and I'm not sure why not. Any ideas? It's as if _.has_key() is
not working correctly for ZClasses. Here is what I did:
1) Apply your version of lib/python/OFS/properties.dtml, restart zope
2) Create Product 'Colors'
3) In Colors, add ZClass 'color'
4) In color add a propertysheet 'info'
5) In info, add tokens property colors_list = "red green blue"
6) Add string property colors_select_variable = "colors_list"
[ now colors_select_variable definitely exists and is displayed]
7) Add selection property colors = "red"
<!--
Traceback (innermost last):
File /usr/share/Zope-2.0.0a4-src/lib/python/ZPublisher/Publish.py,
line 256, in publish_module
File /usr/share/Zope-2.0.0a4-src/lib/python/ZPublisher/Publish.py,
line 161, in publish
File /usr/share/Zope-2.0.0a4-src/lib/python/ZPublisher/mapply.py, line
154, in mapply
(Object: manage_addProperty)
File /usr/share/Zope-2.0.0a4-src/lib/python/ZPublisher/Publish.py,
line 98, in call_object
(Object: manage_addProperty)
File /usr/share/Zope-2.0.0a4-src/lib/python/OFS/PropertySheets.py,
line 406, in manage_addProperty
(Object: info)
File /usr/share/Zope-2.0.0a4-src/lib/python/App/special_dtml.py, line
120, in __call__
(Object: manage)
File
/usr/share/Zope-2.0.0a4-src/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
(Object: manage)
File /usr/share/Zope-2.0.0a4-src/lib/python/DocumentTemplate/DT_In.py,
line 689, in renderwob
(Object: propertyMap)
File
/usr/share/Zope-2.0.0a4-src/lib/python/DocumentTemplate/DT_Util.py, line
315, in eval
(Object: _.has_key(_[id + '_select_variable']))
File <string>, line 0, in ?
File
/usr/share/Zope-2.0.0a4-src/lib/python/DocumentTemplate/DT_Util.py, line
150, in careful_getitem
KeyError: colors_select_variable
-->
TIA
--
Alex Rice | alrice@swcp.com | http://www.swcp.com/~alrice
Current Location: N. Rio Grande Bioregion, Southwestern USA