[Zope-dev] Asking for the type of a variable

Martijn Pieters mj@antraciet.nl
Tue, 09 Nov 1999 23:11:42 +0100


At 22:55 9-11-99 , David S. Harrison wrote:
>Actually, the reason this arises is forms.  I have a series of radio
>buttons in a form.  When submitted to Zope, I notice that if one item
>is selected, the value is a string.  When many items are selected,
>the value is a list of strings.  Since <dtml-in> does not accept a
>single string as an argument, I need to test to see if the incoming
>value is a string or a list of strings before processing it.  I will
>gladly accept any better idioms for handling this case.  The tests
>certainly make the DTML code more complex than I think it should be.


I take it you mean checkboxes. Just append the :list modifier to the 
checkbox name, and it will always be a list, wether the user selected zero, 
one, or more checkboxes:

   <input type=checkbox name="publications:list"
     value="Magazine"> Magazine <br>
   <input type=checkbox name="publications:list"
     value="Book"> Book <br>
   <input type=checkbox name="publications:list"
     value="eZine"> EZine (email magazine) <br>



--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| T: +31 35 7502100 F: +31 35 7502111
| mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
---------------------------------------------