Seing if an attribute exist in an ObjectManager
I have set an image in an ObjectManager object like this: imID = 'laeringsGraf' self._setObject(imID, OFS.Image.Image(imID,'Lærings 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) regarsd Max M
On Tue, 29 May 2001, [iso-8859-1] Max M�ller Rasmussen wrote:
I have set an image in an ObjectManager object like this:
imID = 'laeringsGraf' self._setObject(imID, OFS.Image.Image(imID,'L�rings 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 acquisition. what you need is: if imID not in self.objectIds() : # doesn't exist else: # already exists hoping this helps. bye, Jerome Alet
participants (2)
-
Jerome Alet -
Max Møller Rasmussen