[Zope-Checkins] CVS: Zope2 - ObjectManager.py:1.131.2.4

Andreas Jung andreas@dhcp165.digicool.com
Mon, 2 Apr 2001 09:28:20 -0400


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:
workaround to present a proper long file listing for some FTP clients.
Zope sends "System Processes" as username. This breaks some clients
that expects the username to be one word. The workaround just
removes any spaces from the username.




--- Updated File ObjectManager.py in package Zope2 --
--- ObjectManager.py	2001/03/30 21:26:27	1.131.2.3
+++ ObjectManager.py	2001/04/02 13:28:18	1.131.2.4
@@ -102,6 +102,7 @@
 import App.Common
 from AccessControl import getSecurityManager
 from zLOG import LOG, ERROR
+import string
 import sys,fnmatch,copy
 
 import XMLExportImport
@@ -603,7 +604,7 @@
             all_files = copy.copy(files)
             for f in files:
                 if f[1].meta_type == "Folder":
-                    all_files.extend(findChilds(f[1],''))
+                    all_files.extend(findChilds(f[1]))
                 else:
                     all_files.append(f)
             
@@ -621,9 +622,6 @@
         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):
@@ -632,12 +630,11 @@
             # Note that we have to tolerate failure here, because
             # Broken objects won't stat correctly. If an object fails
             # to be able to stat itself, we will ignore it.
-            try:    stat=marshal.loads(v.manage_FTPstat(REQUEST))
+            try:   stat=marshal.loads(v.manage_FTPstat(REQUEST))
             except: stat=None
             if stat is not None:
                 out=out+((k,stat),)
 
-
         return marshal.dumps(out)   
 
     def manage_FTPstat(self,REQUEST):
@@ -660,8 +657,11 @@
         owner=group='Zope'
         for user, roles in self.get_local_roles():
             if 'Owner' in roles:
-                owner=user
+                # We remove spaces from the username because breaks
+                # the directory listing of some scrubby FTP clients (ajung)
+                owner = string.replace(user," ","")
                 break
+        
         return marshal.dumps((mode,0,0,1,owner,group,0,mtime,mtime,mtime))
 
 
@@ -676,7 +676,7 @@
         raise KeyError, key
 
 
-def findChilds(obj,dirname):
+def findChilds(obj,dirname=''):
     """ recursive walk through the object hierarcy to
     find all childs of an object (ajung)
     """