[Zope] Objet : [Zope] How to test if an object exist

Francois-Regis CHALAOUX Francois-Regis.CHALAOUX@sanofi-synthelabo.com
Thu, 24 Aug 2000 14:26:00 +0200


Hi,

Thanks for the details on hasattr function. I learned a lot ;)
In the meantime, I found an other solution. Have a look.

Bye, FR.

Here I create folders in the folder "self.folder1".
Each new folder has a number at its end (folder11, folder12, etc ...).

def testFolder(self):
    self=self.this()
    sub1=self.folder1
    l = ['1','2','3','4']
    for i in l:
        sub2= "self.folder1" + ".folder1" + i
        folder = "folder1" + i
        try:
            if eval(sub2):
                pass
        except AttributeError:
            sub1.manage_addFolder(folder)
    return 'ok'