[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS - Folder.py:1.1.2.5 IContainer.py:1.1.2.3
Tres Seaver
tseaver@zope.com
Sat, 17 Nov 2001 21:14:30 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS
In directory cvs.zope.org:/tmp/cvs-serv30548
Modified Files:
Tag: Zope-3x-branch
Folder.py IContainer.py
Log Message:
- IContainer.getObject() promises to raise KeyError if named object
not found, and no explicit default is passed; sync implementation
(and argument signarure in interface) with this semantic.
=== Zope3/lib/python/Zope/App/OFS/Folder.py 1.1.2.4 => 1.1.2.5 ===
"""The standard Zope Folder object interface."""
+_RAISE_KEYERROR = []
class Folder:
"""The standard Zope Folder implementation."""
@@ -29,9 +30,14 @@
(name, object) for the objects that appear in the folder."""
return self.data.items()
- def getObject(self, name, default=None):
- """Return the named object of the container, or the default."""
- return self.data.get(name, default)
+ def getObject(self, name, default=_RAISE_KEYERROR):
+ """Return the named object, or the value of the default argument
+ if given and the named object is not found. If no default is
+ given and the object is not found a KeyError is raised."""
+ object = self.data.get(name, default)
+ if object is _RAISE_KEYERROR:
+ raise KeyError, name
+ return object
def hasObject(self, name):
"""Return true if the named object appears in the folder."""
=== Zope3/lib/python/Zope/App/OFS/IContainer.py 1.1.2.2 => 1.1.2.3 ===
+_RAISE_KEYERROR = []
+
class IReadContainer(Interface):
"""An interface for the read aspects of a container. For all methods
that return a sequence of values, the return value is guaranteed to
@@ -25,7 +27,7 @@
"""Return a sequence-like object containing tuples of the form
(name, object) for the objects that appear in the container."""
- def getObject(name, default=None):
+ def getObject(name, default=_RAISE_KEYERROR):
"""Return the named object, or the value of the default argument
if given and the named object is not found. If no default is
given and the object is not found a KeyError is raised."""