On Tue, Aug 24, 2004 at 03:25:17PM +0200, Florent Guillaume wrote:
I'd like to add a method like
def hasObject(self, id): """Test if an object is in the current object.""" for o in self._objects: if o['id'] == id: return 1 return 0
to ObjectManager.
This would bring it in line with BTreeFolder2 (who already has an hasObject method) and we could then always use the most efficient method to test if a folder has a given subobject id.
Opinions ?
I like having such a method, but let's not iterate over all the sub-objects. Why not this? from Acquisition import aq_base ... def hasObject(self, id): """Test if an object is in the current object. """ if hasattr(aq_base(self), id): return 1 return 0 The same idiom is used in ObjectManager.checkValidId, FWIW. -- Paul Winkler http://www.slinkp.com