How to type check OR better list selector ways
<dtml-expr="_.type(some_variable_of_unknown_type)"> causes a name error, while other python builtins like _.string(some_int) work fine. What gives? Is there some other "zopist" way to type-check? More generally, is there a better way to deal with the annoying fact that multiple selectors return a list UNLESS there are <=1 items selected, in which case they return a single item or None? (rather than a list with only one member, in the case of 1 object selected, or an empty list, in the case of none, which would SEEM to be the consistant way to do things, since <dtml-in> wouldn't choke.) =Rob====== ====J===== =====Roos= And more and more, as I see all these prisons going up, and everybody being sent off to prison, with three strikes and so on, they are preparing, really, for a showdown with the American people. They're already talking about using for minor drug offenders the old Army camps that are being shut down. To pen them in. More animal farming. The animals are going to turn one day and bite. And even now, perhaps, as we are chatting, there is some young boy or girl who will grow up and overthrow this government. Because it has overthrown our old republic; it seems to be doing its best to overthrow our Bill of Rights and the Constitution ... -Gore Vidal, novelist, essayist, and cousin of Al Gore 1996 interview on "We the People" with Jerry Brown <www.wtp.org/radio/transcripts/tr960708.html>
Hi, Robert BTW, this is a FAQ, but: use the :list extension in your html. e.g., <select multiple name="<dtml-var form_save_name>:list"> <dtml-in thelistitems> <option value="<dtml-var sequence-item>"><dtml-var sequence-item></option> </dtml-in> </select> Works for checkboxes, too! -- Jim Washington Robert Joseph Roos wrote:
<dtml-expr="_.type(some_variable_of_unknown_type)">
causes a name error, while other python builtins like _.string(some_int) work fine. What gives? Is there some other "zopist" way to type-check?
More generally, is there a better way to deal with the annoying fact that multiple selectors return a list UNLESS there are <=1 items selected, in which case they return a single item or None?
(rather than a list with only one member, in the case of 1 object selected, or an empty list, in the case of none, which would SEEM to be the consistant way to do things, since <dtml-in> wouldn't choke.)
participants (2)
-
Jim Washington -
Robert Joseph Roos