[Zope] checking for existing/nonexisting properties and objects?

Darran Edmundson Darran.Edmundson@anu.edu.au
Sun, 12 Sep 1999 18:25:28 +1000


Consider the following dtml code fragment:

  <dtml-in "objectValues(['Image'])">
     <img src="<dtml-var id>">
     <dtml-if "caption">
        <caption><dtml-var caption></caption>
     </dtml-if>
  </dtml-in>

I use it to loop over all images in a folder,
displaying the image and its caption if such
a property exists.  This snippet fails if
the image doesn't have a "caption" property.
I've been working around this by adding an
empty caption further up the tree but I'd like
to avoid this if possible.

On a related note, I have tried to write dtml
to render an image only if the named object
exists without success.

Any help would be much appreciated, preferably
cc'd to my private email as I receive the
digest version of the list.

Cheers,
Darran.

-- 
Darran Edmundson [Darran.Edmundson@anu.edu.au]