[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS - Folder.py:1.1.2.2 RootFolder.py:1.1.2.2 Container.py:NONE IRootFolder.py:NONE
Brian Lloyd
brian@digicool.com
Fri, 16 Nov 2001 16:35:28 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS
In directory cvs.zope.org:/tmp/cvs-serv10587
Modified Files:
Tag: Zope-3x-branch
Folder.py RootFolder.py
Removed Files:
Tag: Zope-3x-branch
Container.py IRootFolder.py
Log Message:
refactor folder basics
=== Zope3/lib/python/Zope/App/OFS/Folder.py 1.1.2.1 => 1.1.2.2 ===
-from IFolder import IFolder
+from IContainer import IContainer
+
+
+class IFolder(IContainer):
+ """The standard Zope Folder object interface."""
class Folder:
"""The standard Zope Folder implementation."""
__implements__ = IFolder
+
+ def __init__(self):
+ # XXX - fix this to use a btree when persistence is online.
+ self.data = {}
+
+ def objectIds(self):
+ """Return a sequence-like object containing the names of the
+ objects that appear in the container."""
+ return self.data.keys()
+
+ def objectValues(self):
+ """Return a sequence-like object containing the objects that
+ appear in the container."""
+ return self.data.values()
+
+ def objectItems(self):
+ """Return a sequence-like object containing tuples of the form
+ (name, object) for the objects that appear in the container."""
+ return self.data.items()
+
+ def getObject(self, name, default=None):
+ """Return the named object of the container, or the value of the
+ default if given. If no default is given and the named object
+ is not found, None is returned."""
+ return self.data.get(name, default)
+
+ def hasObject(self, name):
+ """Return true if the named object appears in the container."""
+ return self.data.has_key(name)
+
+ def objectCount(self):
+ """Return the number of objects in the container."""
+ return len(self.data)
+
+ def setObject(self, name, object):
+ """Add the given object to the container under the given name."""
+ self.data[name] = object
+
+ def delObject(self, name):
+ """Delete the named object from the container. Raises a KeyError
+ if the object is not found."""
+ del self.data[name]
+
=== Zope3/lib/python/Zope/App/OFS/RootFolder.py 1.1.2.1 => 1.1.2.2 ===
-from Folder import Folder
+from Folder import IFolder, Folder
+
+
+class IRootFolder(IFolder):
+ """The standard Zope root Folder object interface."""
class RootFolder(Folder):
=== Removed File Zope3/lib/python/Zope/App/OFS/Container.py ===
=== Removed File Zope3/lib/python/Zope/App/OFS/IRootFolder.py ===