[Zope] How to test if an object exist

Francois-Regis CHALAOUX Francois-Regis.CHALAOUX@sanofi-synthelabo.com
Wed, 23 Aug 2000 15:51:00 +0200


Hi,

In the following code I test if a folder exists. The folder name to test is
generated on the fly and here I try to simultate it with 'exce' function (may
my error). The first time object2create does not exist and object2create is
well created but if run again the script I obtain the following error :

Errot Type: NameError
Error Value: folder1

How to manage this problem ?

FR.

=====
CODE
=====
def testFolder(self):
    self=self.this()
    sub1=self.folder1
    exec "object2create = 'folder11'"
    try:
        if sub1.object2create:
            return 'Object exists'
    except AttributeError:
        sub1.manage_addFolder(object2create)
        return 'Object created'