[Zope] hasattr in tal:condition

Jean-Francois.Doyon at CCRS.NRCan.gc.ca Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Mon Mar 15 14:25:19 EST 2004


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.

-----Original Message-----
From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
Andre Meyer
Sent: Monday, March 15, 2004 5:41 AM
To: Zope List
Subject: [Zope] hasattr in tal:condition


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()); ... >



_______________________________________________
Zope maillist  -  Zope at 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 )



More information about the Zope mailing list