Re: [Zope-dev] Re: is an object in a folder
def hasObject(self, id): Test if an object is in the current object. return id in self.objectIds() Because then it always computes all ids, before testing presence (second list scan). Time is N+pos(id) whereas with the scan below, time is pos(id) (N being the total number of subobjects). Florent 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 ? Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 71 59 http://nuxeo.com mailto:[EMAIL PROTECTED] ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: is an object in a folder
Why not: def hasObject(self, id): Test if an object is in the current object. return id in self.objectIds() Suresh Florent Guillaume [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 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 ? Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 71 59 http://nuxeo.com mailto:[EMAIL PROTECTED] ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )