RE: [Zope] How to check for a folder's existence and create it if it doesn'texist?
try something like this, assuming the id of the folder you want is 'myFolder': <dtml-if expr="'myFolder' not in objectIds('Folder')"> <dtml-call expr="manage_addFolder('myFolder', 'title of my new folder')"> </dtml-if> The problem with using <dtml-in> is it will try to add the new folder once for every folder in the parent folder, and will fail to create the folder if the parent folder is empty. -Randy
-----Original Message----- From: Paul Zwarts [mailto:paul.zwarts@oratrix.com] Sent: Wednesday, February 28, 2001 8:55 AM To: Chris Muldrow Cc: zope@zope.org Subject: Re: [Zope] How to check for a folder's existence and create it if it doesn'texist?
Hi!
Perhaps something like this:
<dtml-in expr="objectValues('Folder')"> <dtml-if id==2001> Matches <dtml-else> <dtml-call "nameofFolder.manage_addFolder('titleofFolder', 'something else?')"> </dtml-if> </dtml-in>
You'll have to check if that actually works, because somehow it seems wrong... but anyhow, It should be enough to go on....
Im pretty much a newbie, but I had alot of help from the list today, so I try to return the favour : ) Cheers, Paz
Chris Muldrow wrote:
I'm trying create a method to go through a site and create certain folders if they don't already exist. I can check for the existence of the folders with this:
<dtml-in expr="objectValues('Folder')"> <dtml-if "id=='2001'"> It matches<p> </dtml-if>
</dtml-in>
But how do I craft the "else" to create the folder? Obviously, if I throw the <dtml-else> inside the "in" loop, it'll throw itself into the "else" action for every iteration where it doesn't find the named folder.
-- Chris Muldrow, muldrow@mac.com
_______________________________________________ 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 )
From: "Randall F. Kern" <randy@spoke.net> Date: Wed, 28 Feb 2001 12:11:00 -0800 To: "Paul Zwarts" <paul.zwarts@oratrix.com>, "Chris Muldrow" <muldrow@mac.com> Cc: <zope@zope.org> Subject: RE: [Zope] How to check for a folder's existence and create it if it doesn'texist?
<dtml-if expr="'myFolder' not in objectIds('Folder')"> <dtml-call expr="manage_addFolder('myFolder', 'title of my new folder')"> </dtml-if> This worked like a dream! Thanks!
participants (2)
-
Chris Muldrow -
Randall F. Kern