[Zope] detecting if an object exists in a folder

Joh Johannsen jojo@farm9.com
Wed, 31 Jan 2001 14:52:48 -0800


What is the easy way to check if an object exists in a folder?

I have a folder "testfolder" containing a single image "fff".

The following DTML finds it (though I'm sure there are easier ways):

<dtml-in expr="PARENTS[0].testfolder.objectValues(['Image'])">
 got image '<dtml-var id>'<br>
 <dtml-if expr="id=='fff'">
  T1: got string<br>
 <dtml-else>
  T1: did not see: '<dtml-var id>'<br>
 </dtml-if>
 <dtml-call "REQUEST.set('xid', _.str(id))">
 <dtml-if expr="xid=='fff'">
  T2: got string<br>
 <dtml-else>
  T2: did not see: '<dtml-var id>'<br>
 </dtml-if>
</dtml-in>

but the problem is -- both the comparisons above fail. The output on the
page as I see it from my browser:

got image 'fff'
T1: did not see: 'fff'
T2: did not see: 'fff'

So how can I tell if an image of a particular name exists in a folder?

The string comparison fails because whatever it is, "id" is not a
string, and cannot be converted to a string, even though it really looks
like some (top secret zope) code is having no problem doing such a
conversion.

In any case, all I'm really trying to do is to make a DTML method that
will tell me if an image object of a particular name exists in a folder.

Any suggestions?

Thank you,

JJ