[Zope] hasattr in tal:condition

Andre Meyer meyer at acm.org
Mon Mar 15 05:41:15 EST 2004


Dear Zopers

Is it the case that it is not possible to make use of hasattr within a 
tal:condition statement? In a ZPT I need to test whether an attribute of 
here/request is set or not. Unfortunately, this raises an exception, 
which is exactly what I want to prevent...

Here is what the test looks like:

    <span tal:condition="python:test(hasattr(request, results), 1, 
0)">span</span>

Is there a better way to achieve the same?

thanks and regards
Andre

PS in the full version the statement looks as follows:

    <body tal:define="results python:test(hasattr(request, results), 
request.results, here.Catalog()); ... >





More information about the Zope mailing list