[Zope] How do I make an editable lists to fill a selection list?

R. David Murray bitz@bitdance.com
Sat, 8 Apr 2000 16:11:14 -0400 (EDT)


On Fri, 7 Apr 2000, Ed Corrado wrote:
> this point do not want to. What I would like to do is have a list of
> values such as: 'Art' 'Biology' 'Business' 'Chemistry'....
> 
> I would like that this list could easily be edited by someone that knows
> very little about Zope, HTML, DTML, etc. I would also like that this list
> be editable using a web form without the Zope mangement interface, however
> if the mangement interface needs to be used (or some other editor) that is
> acceptable. Once I have this list, I would like to be able to call it into

Well, if you create a Property of type 'tokens' or 'lines' (depending
on whether or not the values can have spaces inside them), then
the management interface could be used to edit the list.  For
example, you could make it a property on the folder that contains
the form you are working on.

> a loop to populate a set of checkboxes. Currently, I have hard-coded these
> checkboxes to be populated in DTML method as follows (The "real"
> application has many more options):
> 
> <dtml-in "('Art', 'Biology', 'Business', 'Chemistry')">
>     <input type=checkbox NAME="database_keywords" value=<dtml-var
> sequence-item>><dtml-var sequence-item>
> </dtml-in>

If you have a property of type tokens or lines, the value will be a
Python sequence, and you can manipulate it with dtml-in as above.

> I would like them (providing they have permission) to be able to easily do
> so by going to a different screen.

If you don't want to use the management interface to udpate this
property, then you can build your own form.  In that form, you
want to build a textarea input box, and you want to code the
name as shown here:

<textarea name="myproperty:tokens">
<dtml-in myproperty><dtml-var sequence-item> </dtml-in>
</textarea>

When this form is submitted, the Zope will make sure the 'myproperty'
variable contains a sequence of tokens instead of a string, and
can be passed on into the

propertysheets.<sheetname>.manage_changeProperties

method of the object holding the property.  (NB: I've used the
above on a ZClass property but not on, say a folder property, so
the name of the method might be wrong for the latter case.)

I hope this at least gets you pointed in the right direction.
There are more detailed examples in the HowTos.

--RDM