[Zope] hasattr in tal:condition

Troy Farrell troy at entheossoft.com
Mon Mar 15 15:54:24 EST 2004


I haven't been following this thread, but your suggestion seems silly.  Use two 
lines in one Page Template:

<span tal:condition="exists: here/request/results" />
<span tal:condition="not: exists: here/request/results" />

Even better, write a python script which returns what you want to display and 
use one line in the ZPT:

<span tal:define="results container/myscript"
       tal:content="results/stuff" />

Sorry if my suggestions are irrelevant.  I'm trying to keep you from doing 
unnecessary work.

Troy

Andre Meyer wrote:
> Thanks for the hint.
> 
> After some experimentation I realise that "exists:" does not help, 
> because it does not have an "else" branch. If I set the exists condition 
> on the body or a span tag, the defined results are visible only within 
> that tag. An else branch must me simulated by a second condition on a 
> tag, but that means that the whole content of the previous one needs to 
> be repeated. However, the whole point of the test was to re-use all the 
> content except for a single statement at the beginning that determines 
> where the results come from. As a result, a neater solution seems to be 
> to have two ZPTs with a single different line (maintenance problem).
> 
> regards
> Andre
> 
> 
> Jean-Francois.Doyon at CCRS.NRCan.gc.ca wrote:
> 
>> Yes, use the "exists:" TAL expression.  So you would do:
>>
>> <span tal:condition="exists: here/request/results" />
>>
>> or something like that ...
>>
>> More info in the ZPT reference ...
>>
>> J.F.



More information about the Zope mailing list