How to check for a folder's existence and create it if it doesn't exist?
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
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 )
I'm not shure if I understand you correctly, but this might do what you're looking for: <dtml-call REQUEST.set('folderExists', 0) <dtml-in expr="objectValues('Folder')"> <dtml-if "id=='2001'"> <dtml-call REQUEST.set('folderExists', 1) </dtml-if> </dtml-in> <dtml-if folderExists> <dtml-else> <dtml-call manage_addFolder....> </dtml-if> ----- Original Message ----- From: Chris Muldrow <muldrow@mac.com> To: <zope@zope.org> Sent: Wednesday, February 28, 2001 5:40 PM Subject: [Zope] How to check for a folder's existence and create it if itdoesn't exist?
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 )
participants (3)
-
Chris Muldrow -
Kees de Brabander -
Paul Zwarts