[CMF-checkins] CVS: Products/CMFCore - DirectoryView.py:1.55

Florent Guillaume fg at nuxeo.com
Wed May 18 16:34:16 EDT 2005


Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv24145/CMFCore

Modified Files:
	DirectoryView.py 
Log Message:
Do not cause ZODB writes or ConflictError if an old DirectoryView with a
non-existing path is left. Sends a warning to stderr about those.
(http://www.zope.org/Collectors/CMF/347)


=== Products/CMFCore/DirectoryView.py 1.54 => 1.55 ===
--- Products/CMFCore/DirectoryView.py:1.54	Wed Apr  6 13:11:24 2005
+++ Products/CMFCore/DirectoryView.py	Wed May 18 16:33:46 2005
@@ -404,17 +404,25 @@
         self._properties = properties
 
     def __of__(self, parent):
-        info = _dirreg.getDirectoryInfo(self._dirpath)
+        dirpath = self._dirpath
+        info = _dirreg.getDirectoryInfo(dirpath)
         if info is None:
             # for DirectoryViews created with CMF versions before 1.5
             # this is basically the old minimalpath() code
-            self._dirpath = normalize(self._dirpath)
-            index = self._dirpath.rfind('Products')
+            dirpath = normalize(dirpath)
+            index = dirpath.rfind('Products')
             if index == -1:
-                index = self._dirpath.rfind('products')
+                index = dirpath.rfind('products')
             if index != -1:
-                self._dirpath = self._dirpath[index+len('products/'):]
-            info = _dirreg.getDirectoryInfo(self._dirpath)
+                dirpath = dirpath[index+len('products/'):]
+            info = _dirreg.getDirectoryInfo(dirpath)
+            if info is not None:
+                # update the directory view with a corrected path
+                self._dirpath = dirpath
+            else:
+                from warnings import warn
+                warn('DirectoryView %s refers to a non-existing path %s'
+                     % (self.id, dirpath), UserWarning)
         if info is None:
             data = {}
             objects = ()



More information about the CMF-checkins mailing list