[Zope] Seing if an attribute exist in an ObjectManager

Jerome Alet alet@unice.fr
Tue, 29 May 2001 14:35:56 +0200 (MET DST)

On Tue, 29 May 2001, [iso-8859-1] Max M=F8ller Rasmussen wrote:

> I have set an image in an ObjectManager object like this:
>     imID =3D 'laeringsGraf'   =20
>     self._setObject(imID, OFS.Image.Image(imID,'L=E6rings graf',''))
>     self._getOb(imID).update_data(data)
> I only want to draw it if it isn't there allready
> How do I then check if it allready exists?
> I guess it's something like::
>     if not hasattr(self, imID): ??
>     or
>     if not self._has_attr(imID)

with hasattr you'll check if the object exists but taking care of the

what you need is:

=09if imID not in self.objectIds() :
=09=09# doesn't exist
=09=09# already exists

hoping this helps.


Jerome Alet