[Zope] Populating a :list variable from the results of a ZSQL method

Phil Harris phil.harris@zope.co.uk
Fri, 10 Nov 2000 10:52:19 -0000


tone,

How about (untested):

where 'dboptions' is the string pulled from the DB, and 'options' is the
list needed.

<dtml-call "REQUEST.set('options',[])">
<dtml-in "_.string.split(dboptions[1:-1],',')">
  <dtml-call "options.append(_.int(_['sequence-item']))">
</dtml-in>

This would then give you take the string "['1','2','3']" and turn it into
the list [1,2,3].

hth

Phil

----- Original Message -----
From: "Tony McDonald" <tony.mcdonald@ncl.ac.uk>
To: "Zope List" <zope@zope.org>
Sent: Friday, November 10, 2000 10:10 AM
Subject: [Zope] Populating a :list variable from the results of a ZSQL
method


> Hi all,
> Say I've got a form with this in it
>
> <select type="checkbox" name="options:list">
> <option value="1">number 1
> <option value="2">number 2
> <option value="3">number 3
> </select>
>
> When this is put into an SQL database, the field 'options' is this
(string)
>
> ['1', '2', '3']  or ['2', '3'] etc.
>
> When I get the data back from the database, 'options' comes back as a
> string, and <dtml-in options> ... </dtml-in> gives errors (basically,
> it can't iterate over a string).
>
> I tried
> <dtml-call "REQUEST.set('new_options:list', options)">
> and then tried iterating over new_options, but the variable didn't
exist...
>
> Has anyone got any solutions for this?
> TIA
> Tone
> ------
> Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
> The Medical School, Newcastle University Tel: +44 191 222 5116
> A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )