[Zope] avoiding 'AttributeError'

Malthe Borch mborch at 3avod.dk
Sat Mar 26 19:15:48 EST 2005


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 at 3avod.dk
 blog: www.3avod.dk/blog/
 crypto-key: 3avod.dk/keys/mborch.asc
--------------------------------------



More information about the Zope mailing list