[Zope] detecting if an object exists in a folder
ender
kthangavelu@earthlink.net
Wed, 31 Jan 2001 16:29:05 -0800
shameless plug.
here's another using <dtml-contract>
<dtml-contract>
Checks REQUEST var foo to see if its an object in the current folder
@author Kapil Thangavelu <k_vertigo@yahoo.com>
@param foo a request var that should conform to an object id
<dtml-param>
foo:existobid,optional
<dtml-exceptions>
foo:error_page
</dtml-contract>
contract's got a lot more to it. you can download from
zope.org/Members/k_vertigo/PageContract.tgz
cheers
kapil
btw. due to stupidity on my part the UserfFilters stuff is broken... i'll fix
it before a general release.
On Wednesday 31 January 2001 15:16, Andy McKay wrote:
> 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 )
>
> _______________________________________________
> 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 )