How about: <p tal:condition="obj/attribute|nothing" tal:replace="obj/attribute" /> Ben
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Malthe Borch Sent: 27 March 2005 00:16 To: zope@zope.org Subject: [Zope] avoiding 'AttributeError'
Hello list, ---
I can't seem to find an elegant solution to checking if an object has a certain attribute. The following fails (i.e. zope dies), if the attribute does not exist:
<p tal:condition="exists: obj/someAttribute" tal:replace="obj/someAttribute" />
Of course, I just want it to skip the tag. Dying is a bit rash.
Specifically, I want to test if a certain CGI parameter has been set, i.e. that the REQUEST object has a certain attribute.
What is the best way to do this in both ZPT and Python?
\malthe
---- mail: mborch@3avod.dk blog: www.3avod.dk/blog/ crypto-key: 3avod.dk/keys/mborch.asc --------------------------------------
_______________________________________________ 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 )