[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
On Tue, Nov 28, 2006 at 10:24:51PM +0000, Mark Barratt wrote:
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'
(snip)
So what basic fact/knowledge am I missing?
This kind of thing is usually a mistaken type assumption. I bet your radiobutton is setting it to "0" rather than 0. -- Paul Winkler http://www.slinkp.com
Paul Winkler wrote:
This kind of thing is usually a mistaken type assumption. I bet your radiobutton is setting it to "0" rather than 0.
Thanks. Yes it was. But neither value=0 (which I think is invalid XHTML), nor value="" makes any difference. Mark Barratt
Hmmm, CGI only returns strings. Sometimes x*1 will give a number (0) even if x is a string ("0")... but I would have said your example should work... Cheers -Terry x On Tue, 28 Nov 2006, Mark Barratt wrote:
Paul Winkler wrote:
This kind of thing is usually a mistaken type assumption. I bet your radiobutton is setting it to "0" rather than 0.
Thanks. Yes it was. But neither value=0 (which I think is invalid XHTML), nor value="" makes any difference.
Mark Barratt _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Terry Brown wrote:
Hmmm, CGI only returns strings. Sometimes x*1 will give a number (0) even if x is a string ("0")... but I would have said your example should work...
Yes, that's what i would have thought <sigh />. I'll move this to the Plone users list - there may be some specific Plone evil involved, though I don't see how. Thanks for the input. Mark Barratt
Mark Barratt wrote:
Paul Winkler wrote:
This kind of thing is usually a mistaken type assumption. I bet your radiobutton is setting it to "0" rather than 0.
Thanks. Yes it was. But neither value=0 (which I think is invalid XHTML), nor value="" makes any difference.
OK, solved. value="" actually works - some kind of cacheing issue seems to have misled me when first testing it. Again, thanks. Mark
Paul Winkler wrote:
On Tue, Nov 28, 2006 at 10:24:51PM +0000, Mark Barratt wrote:
The radio inputs return name="listed" and value 0 or 1
If you change that radio input to name="listed:int" you'll get the behaviour you expect... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Chris Withers -
Mark Barratt -
Paul Winkler -
Terry Brown