[Zope-Checkins] CVS: Zope2 - ObjectManager.py:1.131.2.3
Andreas Jung
andreas@dhcp165.digicool.com
Fri, 30 Mar 2001 16:26:29 -0500
Update of /cvs-repository/Zope2/lib/python/OFS
In directory yetix:/work/zope/Zope2/Zope2/lib/python/OFS
Modified Files:
Tag: ajung_Zope2_FTP_globbing_patch
ObjectManager.py
Log Message:
added support for recursive file listings (ls -R) on the FTP server
--- Updated File ObjectManager.py in package Zope2 --
--- ObjectManager.py 2001/03/30 15:51:53 1.131.2.2
+++ ObjectManager.py 2001/03/30 21:26:27 1.131.2.3
@@ -102,7 +102,7 @@
import App.Common
from AccessControl import getSecurityManager
from zLOG import LOG, ERROR
-import sys,fnmatch
+import sys,fnmatch,copy
import XMLExportImport
customImporters={
@@ -596,6 +596,19 @@
files=self.objectItems()
+ # recursive ride through all subfolders (ls -R) (ajung)
+
+ if REQUEST.environ.get('FTP_RECURSIVE',0) == 1:
+
+ all_files = copy.copy(files)
+ for f in files:
+ if f[1].meta_type == "Folder":
+ all_files.extend(findChilds(f[1],''))
+ else:
+ all_files.append(f)
+
+ files = all_files
+
try:
files.sort()
except AttributeError:
@@ -608,6 +621,9 @@
if globbing is not None:
files = filter(lambda x,g=globbing: fnmatch.fnmatch(x[0],g) , files)
+
+
+
if not (hasattr(self,'isTopLevelPrincipiaApplicationObject') and
self.isTopLevelPrincipiaApplicationObject):
@@ -620,6 +636,8 @@
except: stat=None
if stat is not None:
out=out+((k,stat),)
+
+
return marshal.dumps(out)
def manage_FTPstat(self,REQUEST):
@@ -656,6 +674,21 @@
if request.maybe_webdav_client and not method in ('GET', 'POST'):
return NullResource(self, key, request).__of__(self)
raise KeyError, key
+
+
+def findChilds(obj,dirname):
+ """ recursive walk through the object hierarcy to
+ find all childs of an object (ajung)
+ """
+
+ lst =[]
+ for name,child in obj.objectItems():
+ if child.meta_type=="Folder":
+ lst.extend(findChilds(child,dirname+ obj.id + '/'))
+ else:
+ lst.append( (dirname + obj.id + "/" + name,child) )
+
+ return lst
Globals.default__class_init__(ObjectManager)