[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Zope] boolean weirdness
I think the problem is that the string "0" is not a false value. Both "0" and
"1" are true values. All non-empty strings are true in Python.
Generally you would use integer values in a boolean. The integer 0 is indeed
considered false. From a web form, you can use marshalling to make the value
into an integer such as:
<input type="radio" name="mybool:int" value="1" />True
<input type="radio" name="mybool:int" value="0" />False
See: http://www.zope.org/Members/Zen/howto/FormVariableTypes
for more details on marshalling. Its very useful.
Alternately, you could use an empty string as a false value.
hth,
Casey
On Thursday 02 May 2002 03:36 pm, vsbabu@xxxxxxxxxx allegedly wrote:
> Hi,
>
> We've a ZClass in which there is a property fund_size called boolean.
>
> We had to use a radio group in the form like fund_size:boolean and values as
1 and 0 for true and false.
>
> However, when we had to retrieve it for pre-checking the radio group
according to the value in the property sheet, after some trial and error we
found that
> <dtml-if "fund_size=='1'"> works instead of <dtml-if fund_size> as would've
expected due to "boolean" property.
>
> Took some time to get to the string comparison...
>
> $.02
>
>
> _______________________________________________
> Zope maillist - Zope@xxxxxxxx
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>
_______________________________________________
Zope maillist - Zope@xxxxxxxx
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )
This mailing list archive is a service of Copilotco.