[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Find/tests - testFind.py:1.1.2.3
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 15:34:48 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Find/tests
In directory cvs.zope.org:/tmp/cvs-serv5490/lib/python/Zope/App/OFS/Container/Find/tests
Modified Files:
Tag: Zope-3x-branch
testFind.py
Log Message:
Implemented
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/IContainerPythonification
Along the way:
- Converted most uses of has_key to use in.
- Fixed a bug in Interface names and namesAndDescriptions methods
that caused base class attributes to be missed.
=== Zope3/lib/python/Zope/App/OFS/Container/Find/tests/testFind.py 1.1.2.2 => 1.1.2.3 ===
self._objects = objects
- def objectIds(self):
+ def keys(self):
return [object._id for object in self._objects]
- def objectValues(self):
+ def values(self):
return self._objects
- def objectItems(self):
+ def items(self):
return [(object._id, object) for object in self._objects]
- def getObject(self, id, default=KeyError):
+ def __getitem__(self, id):
for object in self._objects:
if object._id == id:
return object
- if default is KeyError:
- raise KeyError, "Could not find %s" % id
- else:
- return default
+ raise KeyError, "Could not find %s" % id
- def hasObject(self, id):
+ def get(self, id, default=None):
+ for object in self._objects:
+ if object._id == id:
+ return object
+
+ return default
+
+ def __contains__(self, id):
for object in self._objects:
if object.id == id:
return 1
return 0
- def objectCount(self):
+ def __len__(self):
return len(self._objects)
class TestObjectFindFilter(object):
@@ -65,7 +69,7 @@
def matches(self, object):
if IReadContainer.isImplementedBy(object):
- return object.objectCount() == self._count
+ return len(object) == self._count
else:
return 0