[CMF-checkins] CVS: CMF/CMFWorkspaces - Workspace.py:1.7
Casey Duncan
casey@zope.com
Fri, 18 Oct 2002 01:55:14 -0400
Update of /cvs-repository/CMF/CMFWorkspaces
In directory cvs.zope.org:/tmp/cvs-serv13579
Modified Files:
Workspace.py
Log Message:
Fixed FTP traversal and added WebDAV traversal support
Note that due to some acquisition checking done by the ObjectManager base class, standard folderish objects inside a workspace cannot be traversed. Until this is addressed in OM, you must override manage_FTPlist in the derived folderish class and remove the aq check.
=== CMF/CMFWorkspaces/Workspace.py 1.6 => 1.7 ===
--- CMF/CMFWorkspaces/Workspace.py:1.6 Sat Aug 3 22:31:32 2002
+++ CMF/CMFWorkspaces/Workspace.py Fri Oct 18 01:55:13 2002
@@ -42,6 +42,7 @@
import marshal
import Globals
+import webdav
from DateTime import DateTime
from AccessControl import ClassSecurityInfo, User, getSecurityManager
from Products.CMFCore import PortalContent
@@ -84,7 +85,9 @@
)
-class Workspace (PortalContent.PortalContent, DefaultDublinCoreImpl):
+class Workspace (PortalContent.PortalContent,
+ DefaultDublinCoreImpl,
+ webdav.Collection.Collection):
__doc__ = __doc__ # Use the module docstring.
meta_type = 'Workspace'
@@ -160,6 +163,7 @@
# the workspace. Subobjects can implement there own PUT factories to deal
# with it down below.
+ security.declareProtected(ManageWorkspaces, 'manage_FTPlist')
def manage_FTPlist(self, REQUEST):
""" FTP dir list """
# Things currently missing: recursion and globbing support
@@ -175,7 +179,8 @@
out.append((id, stat))
return marshal.dumps(out)
-
+
+ security.declareProtected(ManageWorkspaces, 'manage_FTPstat')
def manage_FTPstat(self, REQUEST):
""" FTP stat for listings """
mode = 0040000
@@ -208,11 +213,28 @@
def __getitem__(self, key):
""" Returns an object based on its unique workspace key """
# Return the referenced object wrapped in our context
- return self._refs[key].dereference(self)
-
+ try:
+ return self._refs[key].dereference(self)
+ except KeyError:
+ request = getattr(self, 'REQUEST', None)
+ if request is not None:
+ method=request.get('REQUEST_METHOD', 'GET')
+ if (request.maybe_webdav_client and
+ not method in ('GET', 'POST')):
+ return webdav.NullResource.NullResource(
+ self, key, request).__of__(self)
+ raise KeyError, key
+
+ security.declareProtected(ManageWorkspaces, 'has_key')
def has_key(self, key):
""" read-only mapping interface """
return self._refs.has_key(key)
+
+ security.declareProtected(ManageWorkspaces, 'objectValues')
+ def objectValues(self):
+ """Required by WebDAV"""
+ return [ref.dereferenceDefault(self) for ref in self._refs.values()]
+
Globals.InitializeClass(Workspace)