[Zope] Create a list using DTML.
Fernando Lujan
flujan at gmail.com
Tue May 24 17:32:31 EDT 2005
On 24/05/05, David H <bluepaul at earthlink.net> wrote:
> >I have a array data type in my DB wich have the following format :
> >{1,2,3} ( ids_test ). Now in my web application, I have a multiple
> >select wich options must be marked as selected if the number is in the
> >array described above. How can I make the above format be converted to
> >a list of elements?
> >
> >For instance:
> >
> ><html>
> ><body>
> ><dtml-in searchIdsTest>
> ><dtml-call "REQUEST.set('ids_test', '['+ids_test[1:-1]+']')">
> ></dtml-in>
> ><form>
> > <select name="id_test" multiple="true">
> > <dtml-in serch_id_test>
> > <option value="&dtml-id_test;" <dtml-if id_test in
> >ids_test> selected="true"</dtml-if>></option>
> > </dtml-in>
> > </select>
> ></form>
> ></body>
> ></html>
> I think you are close. Change <dtml-if ids_test in ids_test> to
> <dtml-if "ids_test in ids_test"> ?
It's working like IN over a string, e.g. the [5,61] will make selected
the number 5,6 and 61.
<dtml-call "REQUEST.set('ids_test', '(' + id_test[1:-1] + ')')">
Where id_test is the result of the database query wich return in this
format: {1,2,3}. I modify it to a (1,2,3) and finally I try the
<dtml-call "REQUEST.set('list', _.list(ids_test))">
Following this api:
list (sequence)
Return a list whose items are the same and in the same order as
sequence's items. If sequence is already a list, a copy is made and
returned, similar to sequence[:]. For instance, list('abc') returns
returns ['a', 'b', 'c'] and list( (1, 2, 3) ) returns [1, 2, 3].
I need a integer-list, is it possible?
--
Fernando Lujan
More information about the Zope
mailing list