[Zope] Checking types in DTML?

Scott Anderson sanderson@ttm.com
Wed, 22 Sep 1999 11:18:44 -0400


Hi all,

Let me state what I'm trying to do, then the problem I've run into with
my solution.

I have a series of HTML option inputs, all with the same name and a
unique value:

<input type="checkbox" name="removeLine" value="6">
<input type="checkbox" name="removeLine" value="7">
<input type="checkbox" name="removeLine" value="8">

In the DTML method that processes the form, if a single check box on the
form was selected, I get a string with the value, eg. removeID = '4'.

If more than one is checked, I get a list: ['32', '34', '50']

The dtml-in tag chokes if passed a string, but works fine for the list.

So, my solution was to test for the type of removeID before using
dtml-in:

<dtml-if "type(removeID) is types.StringType">
treat as string
<dtml-else>
treat as list
</dtml-if>

1) This does not work; I get a NameError on 'type'.  How do I reference
built-in functions? The documentation does not mention type() as
existing on the _ variable, and indeed, "_.type(removeID)" does not work
either.

2) Is there a more elegant way to solve this problem than checking the
type?

Thanks,

-scott