Re: [Zope] Create a list using DTML.

2005-05-27 Thread Fernando Lujan
On 24/05/05, J Cameron Cooper [EMAIL PROTECTED] wrote:

 Personally, I'd probably just do something like::
   {1,2,3}[1:-1].split(',')
 
This code works as expected... Thanks! :)

--
Fernando Lujan
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Create a list using DTML.

2005-05-24 Thread David H

Fernando Lujan wrote:


Hi,

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

Thanks.

Fernando Lujan
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )

 


Fernando,
I think you are close.  Change dtml-if ids_test in ids_test to 
dtml-if ids_test in ids_test ?

David

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Create a list using DTML.

2005-05-24 Thread Fernando Lujan
On 24/05/05, David H [EMAIL PROTECTED] 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
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Create a list using DTML.

2005-05-24 Thread David H




Fernando Lujan wrote:

  
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,
I'm rusty with DTML But I know you can get a list returned using
_.string.split(idstest,',') 

But Id call a python script with idstest as a param, eg
dtml-call "REQUEST.set('myList',pyMakeList( idstest ))"
Eg,

python
import string
idstest = '{1,2,3}' # test only is param

s = s[1:-1]
list = string.split(s,',')
return list

Good luck!
David




___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )