[CMF-checkins] CVS: Products/CMFCore - DirectoryView.py:1.16.22.1
Chris Withers
chrisw@nipltd.com
Fri, 18 Jan 2002 12:31:00 -0500
Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv7091
Modified Files:
Tag: ChrisW-DirectoryView_fix-branch
DirectoryView.py
Log Message:
Working fix but no tests.
=== Products/CMFCore/DirectoryView.py 1.16 => 1.16.22.1 ===
# Ignore version control subdirectories
# and special names.
+def _filter(name):
+ return name not in ('CVS', 'SVN', '.', '..')
+
def _filtered_listdir(path):
- n = filter(lambda name: name not in ('CVS', 'SVN', '.', '..'),
+ n = filter(_filter,
listdir(path))
return n
+def _walker (listdir, dirname, names):
+ names[:]=filter(_filter,names)
+ listdir.extend(names)
+
class DirectoryInformation:
data = None
_v_last_read = 0
+ _v_last_filelist = [] # Only used on Win32
def __init__(self, expanded_fp, minimal_fp):
self.filepath = minimal_fp
@@ -86,19 +94,56 @@
types[strip(obname)] = strip(meta_type)
return types
- def getContents(self, registry):
- changed = 0
- if Globals.DevelopmentMode:
+ if Globals.DevelopmentMode and os.name=='nt':
+
+ def _changed(self):
+ mtime=0
+ filelist=[]
+ try:
+ fp = expandpath(self.filepath)
+ mtime = stat(fp)[8]
+ # Windows directories don't change mtime when a file
+ # in them changes :-(
+ # So keep a list of files as well, and see if that
+ # changes
+ path.walk(fp,_walker,filelist)
+ filelist.sort()
+ except:
+ from zLOG import LOG, ERROR
+ import sys
+ LOG('DirectoryView',
+ ERROR,
+ 'Error checking for directory modification',
+ error=sys.exc_info())
+
+ if mtime != self._v_last_read or filelist != self._v_last_filelist:
+ self._v_last_read = mtime
+ self._v_last_filelist = filelist
+ return 1
+
+ return 0
+
+ elif Globals.DevelopmentMode:
+
+ def _changed(self):
try: mtime = stat(expandpath(self.filepath))[8]
except: mtime = 0
if mtime != self._v_last_read:
self._v_last_read = mtime
- changed = 1
-
+ return 1
+ return 0
+
+ else:
+
+ def _changed(self):
+ return 0
+
+ def getContents(self, registry):
+ changed = self._changed()
if self.data is None or changed:
try:
self.data, self.objects = self.prepareContents(registry,
- register_subdirs=changed)
+ register_subdirs=fish)
except:
LOG('DirectoryView',
ERROR,