24 Aug
2004
24 Aug
'04
3:48 p.m.
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
It would be nice and faster but it doesn't work for non-subobjects attributes. For instance your hasObject('meta_type') or hasObject('isPrincipiaFolderish') would return true. The goal of hasObject, as I see it, is to check if the object is considered a real subobject. That's what BTreeFolder2's does.
The same idiom is used in ObjectManager.checkValidId, FWIW.
Yes but the use case is slightly different IMHO. Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 71 59 http://nuxeo.com mailto:fg@nuxeo.com