[CMF-checkins] SVN: CMF/branches/CMF-1_5-branch/C Interim fix for slow pathwalking implementation in development mode on Windows.

Tres Seaver tseaver at palladion.com
Thu Jul 21 13:07:53 EDT 2005


Log message for revision 37369:
  Interim fix for slow pathwalking implementation in development mode on Windows.
  
  See http://www.zope.org/Collectors/CMF/367.
  
  Note that a better fix would be to leverage pywin32 APIs for file / directory
  monitoring.
  

Changed:
  U   CMF/branches/CMF-1_5-branch/CHANGES.txt
  U   CMF/branches/CMF-1_5-branch/CMFCore/DirectoryView.py

-=-
Modified: CMF/branches/CMF-1_5-branch/CHANGES.txt
===================================================================
--- CMF/branches/CMF-1_5-branch/CHANGES.txt	2005-07-21 16:30:41 UTC (rev 37368)
+++ CMF/branches/CMF-1_5-branch/CHANGES.txt	2005-07-21 17:07:53 UTC (rev 37369)
@@ -2,6 +2,11 @@
 
 Bugs Fixed
 
+    - Apply an interim fix for slow pathwalking implementation in
+      development mode on Windows (http://www.zope.org/Collectors/CMF/367)
+      Note that a better fix would be to leverage pywin32 APIs for
+      file / directory monitoring.
+
     - FSObject.manage_doCustomize() was broken for folderish objects on Zope
       2.8 because manage_permission requires a context to work.
       (see http://www.zope.org/Collectors/CMF/368)

Modified: CMF/branches/CMF-1_5-branch/CMFCore/DirectoryView.py
===================================================================
--- CMF/branches/CMF-1_5-branch/CMFCore/DirectoryView.py	2005-07-21 16:30:41 UTC (rev 37368)
+++ CMF/branches/CMF-1_5-branch/CMFCore/DirectoryView.py	2005-07-21 17:07:53 UTC (rev 37369)
@@ -70,14 +70,19 @@
 
 class _walker:
     def __init__(self, ignore=ignore):
-        self.ignore = ignore
+        # make a dict for faster lookup
+        self.ignore = dict([(x, None) for x in ignore])
 
     def __call__(self, listdir, dirname, names):
-        names = [ (name, stat(path.join(dirname,name))[8])
-                  for name
-                  in names
-                  if name not in self.ignore and not ignore_re.match(name) ]
-        listdir.extend(names)
+        # filter names inplace, so filtered directories don't get visited
+        names[:] = [ name
+                     for name
+                     in names
+                     if name not in self.ignore and not ignore_re.match(name) ]
+        # append with stat info
+        results = [ (name, stat(path.join(dirname,name))[8])
+                    for name in names ]
+        listdir.extend(results)
 
 class DirectoryInformation:
     data = None



More information about the CMF-checkins mailing list