Re: [Zope] How to set selected items in multi-select list from lines property

2006-06-04 Thread Andreas Jung



--On 4. Juni 2006 12:42:38 -1000 John Schinnerer <[EMAIL PROTECTED]> 
wrote:





So far I am only coming up with what seem to be cumbersome solutions that
have unecessary overhead (comparing a list option with every element in
lines property via python script to see if it should be set selected, and
repeating for every list option)...is there a better way?



Since you have to compare each item of the option list against a given list 
of items you *must* do this comparison...how else would you be able which 
items should be selected. The only optimization I can imagine is to convert 
the the list of given items into a dict to perform a lookup in constant 
time instead of O(length_of_given_list).


-aj


--
ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany
Web: www.zopyx.com - Email: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376
E-Publishing, Python, Zope & Plone development, Consulting


pgp7S8cQbzFm1.pgp
Description: PGP signature
___
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 )


[Zope] How to set selected items in multi-select list from lines property

2006-06-04 Thread John Schinnerer

Aloha,

I have an "add" form where a user can add an object.
In one part of the form, the user selects zero or more options from a 
multiple select list.
The selected options populate a lines property of the object when the 
object is added.


I also have an "edit" form where the user can later edit these same 
objects they've created. They can use the same multiple select list to 
change the selected options.
Of course the previously selected options (in the lines property) need 
to be displayed as such when they first visit the edit form.  So...


I need to know how to display the multiple-select list in the "edit" 
form so that the options currently in the lines property are set as 
selected.


I suspect there is some very slick way to do this, maybe with TAL alone...?

So far I am only coming up with what seem to be cumbersome solutions 
that have unecessary overhead (comparing a list option with every 
element in lines property via python script to see if it should be set 
selected, and repeating for every list option)...is there a better way?


Any help appreciated.

thanks,
John S.

--

John Schinnerer - MA, Whole Systems Design
--
- Eco-Living -
Whole Systems Design Services
People - Place - Learning - Integration
[EMAIL PROTECTED]
http://eco-living.net
___
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 )