[Zope] lists, not strings in database
Greg Fischer
gfischer@techgroupinc.com
Tue, 3 Sep 2002 12:12:00 -0700
I need help with saving a select box value. When multiple items are
selected in my form, and then inserted into a SQL server, it is saved as
a string that looks like a list. I have tried to specify the data type
in name value, none of which change the stored value in the database.
This may not be a problem if I only knew how to display the list from
the returned database value.
_________________________________________
Here is the form object(it is generated dynamically from a dtml method
so the size changes):=20
<select name=3D"PeopleInvolved" multiple>
<option>aperson</option>
<option>bperson</option>
<option>cperson</option>
<option>dperson</option>
</select>
_________________________________________
In the database field( a text data type in sql 8) it saves like so:
Insert into table (PeopleInvolved)
values
(<dtml-sqlvar PeopleInvolved type=3D"string">)
['aperson','bperson','cperson']
_________________________________________
When I do a select statement in a zsql method it returns the same value:
select * from table
['aperson','bperson','cperson']
_________________________________________
And to display the results in html is do this:
<table>
<dtml-in sqlMethod>
<dtml-in expr=3D"_.string.split(PeopleInvolved)">
<tr><td><dtml-var sequence-item></td></tr>
</dtml-in>
</dtml-in>
</table>
__________________________________________
Which show like so:
['aperson',
'bperson',
'cperson']
__________________________________________
If I just use <dtml-in PeopleInvolved>
I get an error about not using strings in an "in" tag.
So my question is, How do I save it? OR How do I display it? Without
having the brackets and quotes?
Thanks for any help you have!
Greg Fischer
sysman@tecghroupinc.com