[Zope] Existence and truth

Mark Barratt markb at textmatters.com
Tue Nov 28 17:24:51 EST 2006


[profound subject: sorry the body may be less interesting]

This is so basic, but any help would be appreciated. It's also a Plone 
site, but the problem is about basic tal behaviour so I hope it's 
appropriate:

I have an attribute, 'listed' (a property of 'member') which I want the 
user to be able to set or unset with a radio choice rather than by 
checking or unchecking a checkbox, as provided in default join_form and 
personalize_form.

In personalize_form, I define listed like this:
listed python:request.get('listed', member.getProperty('listed',''))

The radio inputs return name="listed" and value 0 or 1

This works OK, but in the radio input code,

tal:attributes="checked python:test(listed,'checked',None);

*always* returns 'checked'

and the second of these debug lines is *always* displayed, whether 
listed is 0 or 1:

<p>debug: value of listed, after define with getProperty=<span 
tal:content="listed">value</span></p>

<p tal:condition="listed | nothing">debug: this para should print if 
listed is true, ie equals 1</p>

Appendix C of the Zope Book says tal:condition tests for existence and 
truth, and "missing variables, None, zero, empty strings, and empty 
sequences false; all other values are true".

So what basic fact/knowledge am I missing?

Thanks

Mark Barratt


More information about the Zope mailing list