[Zope] Checking types in DTML?
Phil Harris
phil@philh.org
Wed, 22 Sep 1999 16:40:47 +0100
I think if you do it like this:
<input type="checkbox" name="removeLine:list" value="6">
<input type="checkbox" name="removeLine:list" value="7">
<input type="checkbox" name="removeLine:list" value="8">
You'll always get a list of values.
hth
Phil
phil@philh.org
-----Original Message-----
From: anderson@ttm.com [mailto:anderson@ttm.com]On Behalf Of Scott
Anderson
Sent: Wednesday, September 22, 1999 4:19 PM
To: zope@zope.org
Subject: [Zope] Checking types in DTML?
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
_______________________________________________
Zope maillist - Zope@zope.org
http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see:
http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org -
http://www.zope.org/mailman/listinfo/zope-dev )