[Zope] lists, not strings in database
Thomas B. Passin
tpassin@mitretek.org
Tue, 3 Sep 2002 16:57:34 -0400
[Greg Fischer]
[[
That makes sense. So, what I would like is either a comma sepparated
list in the column, or space separated.
aperson bperson cperson
]]
OK, easy enough. If "multiples" is a list of strings, you can get a
comma-separated string for it like this:
<dtml-var "_.string.join(multiples,',')">
You can use any separator, not just ",". You could store this string in the
database. When you want to loop through all the names, you can create a
list from the string like this:
"_.string.split(csv_string,',')"
You can use this list with dtml-in, as in
<dtml-in "_.string.split(csv_string,',')">...</dtml-in>
The only point you still need to handle is to make sure that your html form
always returns a list (otherwise you have to check it before you feed it to
a dtml-in statement). You can make this happen by adding ":list" to the
name of the input element:
<select name='person:list'>...</select>
Cheers,
Tom P