[Zope-dev] is an object in a folder
Dieter Maurer
dieter at handshake.de
Tue Aug 31 15:17:24 EDT 2004
Florent Guillaume wrote at 2004-8-24 15:25 +0200:
>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 would use "hasattr(aq_base(self), id)" (as someone else already suggested).
Almost always it is not relevant whether "id" identifies a true
subobject (in the "ObjectManager" sense) or another attribute.
--
Dieter
More information about the Zope-Dev
mailing list