[CMF-checkins] CVS: CMF - DirectoryView.py:1.8 FSDTMLMethod.py:1.5 FSPythonScript.py:1.7

shane@digicool.com shane@digicool.com
Mon, 30 Apr 2001 15:23:50 -0400 (EDT)


Update of /cvs-repository/CMF/CMFCore
In directory korak:/tmp/cvs-serv31333

Modified Files:
	DirectoryView.py FSDTMLMethod.py FSPythonScript.py 
Log Message:
Zope 2.4 compatibility



--- Updated File DirectoryView.py in package CMF --
--- DirectoryView.py	2001/04/14 22:44:42	1.7
+++ DirectoryView.py	2001/04/30 19:23:48	1.8
@@ -245,7 +245,11 @@
                 else:
                     name = entry
                     ext = ''
-                if not name or bad_id(entry) != -1 or name == 'REQUEST':
+                if not name or name == 'REQUEST':
+                    # Not an allowable id.
+                    continue
+                mo = bad_id(name)
+                if mo is not None and mo != -1:  # Both re and regex formats
                     # Not an allowable id.
                     continue
                 t = None

--- Updated File FSDTMLMethod.py in package CMF --
--- FSDTMLMethod.py	2001/04/24 14:12:13	1.4
+++ FSDTMLMethod.py	2001/04/30 19:23:48	1.5
@@ -96,6 +96,9 @@
 from CMFCorePermissions import View, ViewManagementScreens, FTPAccess
 from DirectoryView import registerFileExtension, registerMetaType, expandpath
 from FSObject import FSObject
+try:
+    from AccessControl import full_read_guard
+except ImportError: pass
 
 
 class FSDTMLMethod(FSObject, Globals.HTML):
@@ -190,7 +193,12 @@
         result = decapitate(r, RESPONSE)
         return result
 
-    validate = DTMLMethod.validate
+    # Zope 2.3.x way:
+    def validate(self, inst, parent, name, value, md):
+        return getSecurityManager().validate(inst, parent, name, value)
+    # Zope 2.4.x way:
+    def read_guard(self, ob):
+        return full_read_guard(ob)
 
     security.declareProtected(FTPAccess, 'manage_FTPget')
     security.declareProtected(ViewManagementScreens, 'PrincipiaSearchSource',

--- Updated File FSPythonScript.py in package CMF --
--- FSPythonScript.py	2001/04/24 14:12:13	1.6
+++ FSPythonScript.py	2001/04/30 19:23:48	1.7
@@ -144,7 +144,6 @@
         try: data = file.read()
         finally: file.close()
         self._write(data)
-        self._makeFunction(1)
 
     def _validateProxy(self, roles=None):
         pass
@@ -191,30 +190,50 @@
       'ZScriptHTML_tryForm', 'PrincipiaSearchSource',
       'document_src', 'params', 'body')
 
-    # We can't use PythonScript as a base class since there are
-    # many ways to modify it.  Instead, we copy methods. :-/
-    ZScriptHTML_tryParams = PythonScript.ZScriptHTML_tryParams
-    _checkCBlock = PythonScript._checkCBlock
-    _newfun = PythonScript._newfun
-    _makeFunction = PythonScript._makeFunction
-    _metadata_map = PythonScript._metadata_map
-    read = PythonScript.read
-    document_src = PythonScript.document_src
-    PrincipiaSearchSource = PythonScript.PrincipiaSearchSource
-    params = PythonScript.params
-    body = PythonScript.body
-    get_size = PythonScript.get_size
+    def ZScriptHTML_tryParams(self):
+        """Parameters to test the script with."""
+        param_names = []
+        for name in self._params.split(','):
+            name = name.strip()
+            if name and name[0] != '*':
+                param_names.append(name.split('=', 1)[0])
+        return param_names
+
+    def read(self):
+        ps = PythonScript(self.id)
+        ps._body = self._body
+        ps._params = self._params
+        return ps.read()
+        
+    def document_src(self, REQUEST=None, RESPONSE=None):
+        """Return unprocessed document source."""
+
+        if RESPONSE is not None:
+            RESPONSE.setHeader('Content-Type', 'text/plain')
+        return self.read()
+
+    def PrincipiaSearchSource(self):
+        "Support for searching - the document's contents are searched."
+        return "%s\n%s" % (self._params, self._body)
+
+    def params(self): return self._params
+    def body(self): return self._body
+    def get_size(self): return len(self._body)
 
     security.declareProtected(FTPAccess, 'manage_FTPget')
-    manage_FTPget = PythonScript.manage_FTPget
-
-    _write = PythonScript.write
-
-    def ZCacheable_invalidate(self):
-        # Waaa
-        pass
-
-    _p_changed = 0  # _write() expects this.  :-(
+    def manage_FTPget(self):
+        "Get source for FTP download"
+        self.REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')
+        return self.read()
+
+    def _write(self, text):
+        ps = PythonScript(self.id)
+        ps.write(text)
+        ps._makeFunction()
+        self._v_f = ps._v_f
+        self._body = ps._body
+        self._params = ps._params
+        self.func_code = ps.func_code
     
 
 Globals.InitializeClass(FSPythonScript)