[Zope] ZPT Help!

Paul Winkler pw_lists at slinkp.com
Tue Jul 20 13:21:23 EDT 2004


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


More information about the Zope mailing list