testing for data type

Jonathan Bowlas me at jonbowlas.com
Sat Jul 29 06:57:45 EDT 2006


Hi Listers,

 

I have a requirement to test for a data type could someone tell me if this
is possible in python?

 

Basically I have a ZPT in Zope that users can select checkboxes in a form
which pass arguments for a python function, however if there is only one
checkbox selected it is passed as a string whereas more than one checkbox is
passed as a list. Therefore if my function is required to perform an action
based on each argument passed in the list the function works correctly but
if it is passed as a string nothing happens.

 

This is my function:

selecteddeptcodes = context.REQUEST.DEPTCODE

currentstatus = context.REQUEST.STATUS

 

if currentstatus == 'pending':

 for dptcd in selecteddeptcodes:

   context.changetolive(DEPTCODE=dptcd)

if currentstatus == 'old':

 for dptcd in selecteddeptcodes:

   context.changetopending(DEPTCODE=dptcd)

return context.pub_dept_form(context, context.REQUEST, message='Updated
Status')

 

The argument in question is selecteddeptcodes.

 

I tried to make my function conditional based on the length of the argument
passed but if it's just one checkbox value passed the length of the argument
is 2 (which is the number of chars passed in the string) and if there are
two checkboxes the length of the argument (which is the number of items in
the list) is also 2. So that doesn't help.

 

Any assistance would be appreciated.

 

Jon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060729/4966b6a9/attachment.html>


More information about the Python-list mailing list