[Zope] detecting if an object exists in a folder

Andy McKay andym@ActiveState.com
Wed, 31 Jan 2001 15:16:24 -0800


Heres one:

<dtml-if "'x' in objectIds()">
found
<dtml-else>
not found
</dtml-if>

--
  Andy McKay.


----- Original Message ----- 
From: "Joh Johannsen" <jojo@farm9.com>
To: "zope" <zope@zope.org>
Sent: Wednesday, January 31, 2001 2:52 PM
Subject: [Zope] detecting if an object exists in a folder


> 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
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>