> 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 Guillaume, Nuxeo (Paris, France)
+33 1 40 33 71 59  http://nuxeo.com  mailto:[EMAIL PROTECTED]
Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to