[Zope] avoiding 'AttributeError'
Ben Mason
ben at benweb.co.uk
Sun Mar 27 05:22:01 EST 2005
How about:
<p tal:condition="obj/attribute|nothing"
tal:replace="obj/attribute" />
Ben
> -----Original Message-----
> From: zope-bounces at zope.org [mailto:zope-bounces at zope.org] On
> Behalf Of Malthe Borch
> Sent: 27 March 2005 00:16
> To: zope at 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 at 3avod.dk
> blog: www.3avod.dk/blog/
> crypto-key: 3avod.dk/keys/mborch.asc
> --------------------------------------
>
> _______________________________________________
> 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