That's work great, thanks Paul! -----Original Message----- From: zope-bounces+michael=centurysoftware.com.au@zope.org [mailto:zope-bounces+michael=centurysoftware.com.au@zope.org] On Behalf Of Paul Winkler Sent: Wednesday, 21 July 2004 3:21 AM To: zope@zope.org Subject: Re: [Zope] ZPT Help! On Tue, Jul 20, 2004 at 03:59:22PM +1000, Michael Fox wrote:
If there is no matching image I want to display an "image unavailable", but can't get this to work.
<span tal:define="image string:${here/id}.jpg">
<span tal:replace="image"></span>
<span tal:condition="not:python:here.objectIds(image)">
That can't work. objectIds() returns a list of IDs and takes no arguments. The simplest thing would be: <span tal:condition="python:image not in here.objectIds()" /> That could be problematically slow if there are a whole lot of objects in the folder. You could also try: <span tal:condition="python:not hasattr(here, image)" /> ... but that is only good if you know that objects with the image ID will not be acquired from elsewhere in the current context. -- Paul Winkler http://www.slinkp.com _______________________________________________ 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 )
<span tal:condition="python:not hasattr(here, image)" />
... but that is only good if you know that objects with the image ID will not be acquired from elsewhere in the current context.
...and hasattr is generally "bad" in a Zope context. I'd use: <span tal:condition="not:here/?image|nothing"> Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (2)
-
Chris Withers -
Michael Fox