[Zope] finding the type of an object
Jim Washington
jwashin@vt.edu
Mon, 03 Apr 2000 09:06:03 -0400
Hi, Allen
try:
<SELECT NAME="aname:list" MULTIPLE>
Your question is frequently asked and a longer explanation may be found
in a search of the mailing list archives. In short, however, the above
casts 'aname' to a list so your form's action can deal with it always as
a sequence.
> I need to test the type of an object for the following reason:
> I have a form, one of the inputs being a <SELECT NAME="name" MULTIPLE>
> etc.
>
> Now, when there are more than one item selected in this <SELECT> list,
> then the variable
> <dtml-var name> is a list (think) which can be used in a <dtml-in name>
> </dtml-in> iteration. The problem is if the user selects one item, then
> the variable "name" is a string, containing the one item that was
> selected. The problem is that if one simply does a <dtml-in name>
> iteration without checking the type of the variable "name", then the
> method will fail when the user only selects one item from the list.
> Hence I need to know the type of the variable "name". How do I find this
> out? Is it possible to call the python function type() from within a
> dtml method? If not, how else does one handle this situation?
--
Jim Washington
Center for Assessment, Evaluation and Educational Programming
Department of Teaching and Learning, Virginia Tech