[OT]Newbie help - test for data type

Bruno Desthuilliers onurb at xiludom.gro
Mon Jul 31 05:37:03 EDT 2006


Jonathan Bowlas wrote:
> 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. 

You should have posted this on Zope's mailing-list.

<OT>
There's a mechanism in Zope to handle this case, cf section "Passing
Parameters to Scripts" in:
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/DTML.stx/ScriptingZope.stx

The mechanism is based on 'decorating' forms fields names with type
annotation. In you case, this would look like:

<form name='xxx' action='yyy' method='POST'>
<tal:repeat repeat="code deptcodes">
  <input type="checkbox" name='selecteddeptcodes:list' value=''
         tal:attribute="value code" />
</tal:repeat>
<!-- rest of the form here -->
</form>

</OT>

HTH



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list