[Zope] Casting to a list
Daniel.Weber@SEMATECH.Org
Daniel.Weber@SEMATECH.Org
Wed, 22 Mar 2000 12:45:39 -0600
Ihis didn't work, then? Looks better than what I came up with, which, for the
list vs. string situation goes like:
<dtml-try>
<dtml-in string_or_list_var>
list stuff...
</dtml-in>
<dtml-except>
non-list stuff...
</dtml-try>
If you have a string with multiple values to split, use the _.string.split()
function, as...
<dtml-in "_.string.split(str [,separator])">
This will probably choke on lists, though. Combine the two for a wholesome,
good-start-to-your day breakfast code. :-)
> -----Original Message-----
> From: Ken Kinder [mailto:kkinder@messagemedia.com]
> Sent: Wednesday, March 22, 2000 12:31 PM
> To: zope@zope.org
> Subject: [Zope] Casting to a list
>
>
> Another question (soon I'll start answering more on this list :) - I
> have a set of checkboxes with the same name that I iterate through
> using dtml-in. However, when only one checkbox is checked, dtml-in
> complains that a string cannot be used as input, it expects a
> sequence. My initial thought was to do this:
>
> <dtml-if "type(var) == type('')">
> ... (do not iterate)
> <dtml-else>
> <dtml-in var>
> ...
> </dtml-in>
> </dtml-if>
>
> How can I either cast a string to a list w/o messing up an existing
> list, or gain access to Python functions such as type() from a
> dtml-if statement?
>
> --
> Ken Kinder
> 303.381.7631
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>