[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/VFS - VFSContainerView.py:1.1.4.4
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 15:34:48 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/VFS
In directory cvs.zope.org:/tmp/cvs-serv5490/lib/python/Zope/App/OFS/Container/Views/VFS
Modified Files:
Tag: Zope-3x-branch
VFSContainerView.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/Views/VFS/VFSContainerView.py 1.1.4.3 => 1.1.4.4 ===
def exists(self, name):
'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
- return self._container.hasObject(name)
+ return name in self._container
def listdir(self, with_stats=0, pattern='*'):
'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
t = time.time()
- file_list = self._container.objectIds()
+ file_list = self._container.keys()
# filter them using the pattern
file_list = list(
filter(lambda f, p=pattern, fnm=fnmatch.fnmatch: fnm(f, p),
@@ -75,7 +75,7 @@
else:
result = []
for file in file_list:
- obj = self._container.getObject(file)
+ obj = self._container[file]
size = 0
# XXX Should be much nicer
if IContainer.isImplementedBy(obj):
@@ -92,22 +92,22 @@
def mkdir(self, name, mode=777):
'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
- if not self._container.hasObject(name):
+ if not (name in self._container):
obj = Folder()
self._container.setObject(name, obj)
def remove(self, name):
'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
- return self._container.delObject(name)
+ del self._container[name]
def rmdir(self, name):
'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
- return self._container.delObject(name)
+ del self._container[name]
def rename(self, old, new):
'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
- obj = self._container.getObject(old)
- self._container.delObject(old)
+ obj = self._container[old]
+ del self._container[old]
self._container.setObject(new, obj)
@@ -116,11 +116,11 @@
# XXX This should become much, much smarter later. Based on the
# data and the file ending, it should pick the right object type.
# *** Waiting for Jim's file extension proposal and code to land ***
- if not self._container.hasObject(name):
+ if not (name in self._container):
obj = File()
self._container.setObject(name, obj)
else:
- obj = self._container.getObject(name)
+ obj = self._container[name]
vfs_view = getView(obj, 'vfs', XXXRequest(IVFSView))
vfs_view.write(mode, instream, start)