[CMF-checkins] CVS: CMF/CMFCore - FSDTMLMethod.py:1.12

Shane Hathaway shane@cvs.zope.org
Fri, 16 Aug 2002 09:45:05 -0400


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv10048/CMFCore

Modified Files:
	FSDTMLMethod.py 
Log Message:
Finished fixing collector #37, giving sanity back to FSDTMLMethods.  With
yesterday's patch, read_raw() calls _updateFromFS() which ends up calling
read_raw() again.  This patch breaks the recursion.

The fix isn't very satisfying since this could potentially happen elsewhere,
but at least I managed to avoid relying on thread locks.


=== CMF/CMFCore/FSDTMLMethod.py 1.11 => 1.12 ===
--- CMF/CMFCore/FSDTMLMethod.py:1.11	Sat Aug  3 22:31:30 2002
+++ CMF/CMFCore/FSDTMLMethod.py	Fri Aug 16 09:45:05 2002
@@ -56,6 +56,8 @@
     security.declareProtected(ViewManagementScreens, 'manage_main')
     manage_main = Globals.DTMLFile('custdtml', _dtmldir)
 
+    _reading = 0
+
     def __init__(self, id, filepath, fullname=None, properties=None):
         FSObject.__init__(self, id, filepath, fullname, properties)
         # Normally called via HTML.__init__ but we don't need the rest that
@@ -71,15 +73,21 @@
         file = open(fp, 'rb')
         try:
             data = file.read()
-        finally: file.close()
+        finally:
+            file.close()
         self.raw = data
         if reparse:
-            self.cook()
+            self._reading = 1  # Avoid infinite recursion
+            try:
+                self.cook()
+            finally:
+                self._reading = 0
 
     # Hook up chances to reload in debug mode
     security.declarePrivate('read_raw')
     def read_raw(self):
-        self._updateFromFS()
+        if not self._reading:
+            self._updateFromFS()
         return Globals.HTML.read_raw(self)
 
     #### The following is mainly taken from OFS/DTMLMethod.py ###