Zope Question
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon Mar 18 04:07:13 EST 2002
Thomas Guettler <newsgroups at thomas-guettler.de> wrote in
news:3C950D0B.60602 at thomas-guettler.de:
> But I can't figure out how to insert
>> either CHECKED or nothing depending on the state of a variable.
>>
>
> One solution would be to do it like this (I use pseudo-code since I
> am new to page templates, and don't want to look up the syntax):
>
> if checked==true
> <input type="radio" name="foo" checked="yes">
> else
> <input type="radio" name="foo">
>
You just do it like this:
<div tal:define="trueexpr python:1; falseexpr python:0;
emptystring python:''; fullstring string:Hello;">
<input type="radio" name="radios"
tal:attributes="checked trueexpr"> I'm checked<br>
<input type="radio" name="radios"
tal:attributes="checked falseexpr"> I'm not.<br>
<input type="radio" name="radios1"
tal:attributes="checked fullstring"> I'm checked<br>
<input type="radio" name="radios1"
tal:attributes="checked emptystring"> I'm not.<br>
</div>
The page type must be text/html for this to work.
Zope's templates have a list of attributes in HTML that are given in a
boolean form (compact, nowrap, ismap, declare, noshade, checked, disabled,
readonly, multiple, selected, noresize, and defer).
Strangely this list is declared in two separate places in the source, and
only used in one place!
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list