[CMF-checkins] CVS: CMF - CatalogTool.py:1.11 FSDTMLMethod.py:1.4 FSImage.py:1.8 FSObject.py:1.3 FSPropertiesObject.py:1.5 FSPythonScript.py:1.6 TypesTool.py:1.11 WorkflowTool.py:1.5 utils.py:1.9

shane@digicool.com shane@digicool.com
Tue, 24 Apr 2001 10:12:14 -0400 (EDT)


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

Modified Files:
	CatalogTool.py FSDTMLMethod.py FSImage.py FSObject.py 
	FSPropertiesObject.py FSPythonScript.py TypesTool.py 
	WorkflowTool.py utils.py 
Log Message:
Various minor changes to improve startup time



--- Updated File CatalogTool.py in package CMF --
--- CatalogTool.py	2001/04/12 19:07:43	1.10
+++ CatalogTool.py	2001/04/24 14:12:13	1.11
@@ -91,7 +91,7 @@
 
 import os
 from utils import UniqueObject, _checkPermission, _getAuthenticatedUser
-from utils import getToolByName
+from utils import getToolByName, _dtmldir
 from Products.ZCatalog.ZCatalog import ZCatalog
 from Globals import InitializeClass, package_home, DTMLFile
 import urllib
@@ -102,7 +102,6 @@
 from utils import mergedLocalRoles
 import CMFCorePermissions
 
-_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
 
 class IndexableObjectWrapper:
 

--- Updated File FSDTMLMethod.py in package CMF --
--- FSDTMLMethod.py	2001/04/11 19:28:09	1.3
+++ FSDTMLMethod.py	2001/04/24 14:12:13	1.4
@@ -92,6 +92,7 @@
 from AccessControl import ClassSecurityInfo, getSecurityManager, Permissions
 from OFS.DTMLMethod import DTMLMethod, decapitate, guess_content_type
 
+from utils import _dtmldir
 from CMFCorePermissions import View, ViewManagementScreens, FTPAccess
 from DirectoryView import registerFileExtension, registerMetaType, expandpath
 from FSObject import FSObject
@@ -116,7 +117,7 @@
     security.declareObjectProtected(View)
 
     security.declareProtected(ViewManagementScreens, 'manage_main')
-    manage_main = Globals.HTMLFile('dtml/custdtml', globals())
+    manage_main = Globals.DTMLFile('custdtml', _dtmldir)
 
     def __init__(self, id, filepath, fullname=None, properties=None):
         FSObject.__init__(self, id, filepath, fullname, properties)
@@ -128,14 +129,15 @@
         """Create a ZODB (editable) equivalent of this object."""
         return DTMLMethod(self.read(), __name__=self.getId())
 
-    def _readFile(self):
+    def _readFile(self, reparse):
         fp = expandpath(self._filepath)
         file = open(fp, 'rb')
         try:
             data = file.read()
         finally: file.close()
         self.raw = data
-        self.cook()
+        if reparse:
+            self.cook()
 
     # Hook up chances to reload in debug mode
     security.declarePrivate('read_raw')

--- Updated File FSImage.py in package CMF --
--- FSImage.py	2001/04/23 08:17:55	1.7
+++ FSImage.py	2001/04/24 14:12:13	1.8
@@ -93,6 +93,7 @@
 from webdav.common import rfc1123_date
 from OFS.Image import Image, getImageInfo
 
+from utils import _dtmldir
 from CMFCorePermissions import ViewManagementScreens, View
 from FSObject import FSObject
 from DirectoryView import registerFileExtension, registerMetaType, expandpath
@@ -116,31 +117,22 @@
         FSObject.__init__(self, id, filepath, fullname, properties)
 
     security.declareProtected(ViewManagementScreens, 'manage_main')
-    manage_main = Globals.HTMLFile('dtml/custimage', globals())
+    manage_main = Globals.DTMLFile('custimage', _dtmldir)
+    content_type = 'unknown/unknown'
 
     def _createZODBClone(self):
-        return Image(self.getId(), '', self._readFile())
+        return Image(self.getId(), '', self._readFile(1))
 
-    def _readFile(self):
+    def _readFile(self, reparse):
         fp = expandpath(self._filepath)
         file = open(fp, 'rb')
         try: data = file.read()
         finally: file.close()
-
-        # Only parse out image info if the file was changed, because this file
-        # is read every time the image is requested.
-        try:    mtime=os.stat(fp)[8]
-        except: mtime=0
-        if mtime != self._file_mod_time:
-            self._file_mod_time = mtime
-        ct, width, height = getImageInfo( data )
-        if ct != getattr( self, 'content_type', None ):
+        if reparse or self.content_type == 'unknown/unknown':
+            ct, width, height = getImageInfo( data )
             self.content_type = ct
-        if width != getattr( self, 'width', None ):
             self.width = width
-        if height != getattr( self, 'height', None ):
             self.height = height
-
         return data
 
     #### The following is mainly taken from OFS/Image.py ###
@@ -149,12 +141,10 @@
 
     _image_tag = Image.tag
     security.declareProtected(View, 'tag')
-    def tag(self, height=None, width=None, alt=None,
-            scale=0, xscale=0, yscale=0, **args):
+    def tag(self, *args, **kw):
         # Hook into an opportunity to reload metadata.
-        self._readFile()
-        return apply(self._image_tag, (height, width, alt, scale, xscale, 
-            yscale), args)
+        self._updateFromFS()
+        return apply(self._image_tag, args, kw)
 
     security.declareProtected(View, 'index_html')
     def index_html(self, REQUEST, RESPONSE):
@@ -164,7 +154,8 @@
         Returns the contents of the file or image.  Also, sets the
         Content-Type HTTP header to the objects content type.
         """
-        data = self._readFile()
+        self._updateFromFS()
+        data = self._readFile(0)
         # HTTP If-Modified-Since header handling.
         header=REQUEST.get_header('If-Modified-Since', None)
         if header is not None:
@@ -200,7 +191,7 @@
 
         Returns the content type (MIME type) of a file or image.
         """
-        self._readFile()
+        self._updateFromFS()
         return self.content_type
 
 Globals.InitializeClass(FSImage)

--- Updated File FSObject.py in package CMF --
--- FSObject.py	2001/04/12 19:02:52	1.2
+++ FSObject.py	2001/04/24 14:12:13	1.3
@@ -124,7 +124,7 @@
         
         try: self._file_mod_time = stat(fp)[8]
         except: pass
-        self._readFile()
+        self._readFile(0)
 
     security.declareProtected(CMFCorePermissions.ViewManagementScreens,
         'manage_doCustomize')
@@ -150,11 +150,12 @@
         """Create a ZODB (editable) equivalent of this object."""
         raise NotImplemented, "This should be implemented in a subclass."
 
-    def _readFile(self):
+    def _readFile(self, reparse):
         """Read the data from the filesystem.
         
-        Read the file (indicated by exandpath(self._filepath), and parse the
-        data if necessary.
+        Read the file indicated by exandpath(self._filepath), and parse the
+        data if necessary.  'reparse' is set when reading the second
+        time and beyond.
         """
         raise NotImplemented, "This should be implemented in a subclass."
 
@@ -167,7 +168,7 @@
             except: mtime=0
             if mtime != self._file_mod_time:
                 self._file_mod_time = mtime
-                self._readFile()
+                self._readFile(1)
 
     security.declareProtected(CMFCorePermissions.View, 'get_size')
     def get_size(self):

--- Updated File FSPropertiesObject.py in package CMF --
--- FSPropertiesObject.py	2001/04/23 08:11:55	1.4
+++ FSPropertiesObject.py	2001/04/24 14:12:13	1.5
@@ -94,6 +94,7 @@
 from ZPublisher.Converters import get_converter
 from AccessControl import ClassSecurityInfo
 
+from utils import _dtmldir
 from DirectoryView import registerFileExtension, registerMetaType, expandpath
 from CMFCorePermissions import ViewManagementScreens
 from FSObject import FSObject
@@ -108,7 +109,7 @@
     security = ClassSecurityInfo()
 
     security.declareProtected(ViewManagementScreens, 'manage_main')
-    manage_main = Globals.HTMLFile('dtml/custprops', globals())
+    manage_main = Globals.DTMLFile('custprops', _dtmldir)
 
     # Declare all (inherited) mutating methods private.
     security.declarePrivate('manage_addProperty',
@@ -152,7 +153,7 @@
 
         return obj
 
-    def _readFile(self):
+    def _readFile(self, reparse):
         """Read the data from the filesystem.
         
         Read the file (indicated by exandpath(self._filepath), and parse the

--- Updated File FSPythonScript.py in package CMF --
--- FSPythonScript.py	2001/04/12 19:02:35	1.5
+++ FSPythonScript.py	2001/04/24 14:12:13	1.6
@@ -94,6 +94,7 @@
 from Products.PythonScripts.PythonScript import PythonScript
 from Shared.DC.Scripts.Script import Script, defaultBindings
 
+from utils import _dtmldir
 from CMFCorePermissions import ViewManagementScreens, View, FTPAccess
 from DirectoryView import registerFileExtension, registerMetaType, expandpath
 from FSObject import FSObject
@@ -124,7 +125,7 @@
         self.ZBindings_edit(defaultBindings)
 
     security.declareProtected(ViewManagementScreens, 'manage_main')
-    manage_main = Globals.DTMLFile('dtml/custpy', globals())
+    manage_main = Globals.DTMLFile('custpy', _dtmldir)
 
     def _createZODBClone(self):
         """Create a ZODB (editable) equivalent of this object."""
@@ -132,7 +133,7 @@
         obj.write(self.read())
         return obj
 
-    def _readFile(self):
+    def _readFile(self, reparse):
         """Read the data from the filesystem.
         
         Read the file (indicated by exandpath(self._filepath), and parse the

--- Updated File TypesTool.py in package CMF --
--- TypesTool.py	2001/04/12 13:58:44	1.10
+++ TypesTool.py	2001/04/24 14:12:13	1.11
@@ -90,16 +90,14 @@
 __version__='$Revision$'[11:-2]
 
 import OFS
-from Globals import InitializeClass, HTMLFile, package_home
-from utils import UniqueObject, SimpleItemWithProperties, tuplize
-import os, string
+from Globals import InitializeClass, HTMLFile
+from utils import UniqueObject, SimpleItemWithProperties, tuplize, _dtmldir
+import string
 from AccessControl import getSecurityManager, ClassSecurityInfo
 from Acquisition import aq_base
 import Products, CMFCorePermissions
 
 from CMFCorePermissions import View, ManagePortal, AccessContentsInformation
-
-_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
 
 _marker = []  # Create a new marker.
 

--- Updated File WorkflowTool.py in package CMF --
--- WorkflowTool.py	2001/04/07 23:14:03	1.4
+++ WorkflowTool.py	2001/04/24 14:12:13	1.5
@@ -90,20 +90,17 @@
 
 
 import sys
-from utils import UniqueObject, _checkPermission, getToolByName
+from utils import UniqueObject, _checkPermission, getToolByName, _dtmldir
 from OFS.Folder import Folder
-from Globals import InitializeClass, PersistentMapping, DTMLFile, package_home
+from Globals import InitializeClass, PersistentMapping, DTMLFile
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base
 from WorkflowCore import WorkflowException
 from CMFCorePermissions import ManagePortal
-import os
 from string import join, split, replace, strip
 
 AUTO_MIGRATE_WORKFLOW_TOOLS = 1  # This will later be set to 0.
 
-
-_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
 
 _marker = []  # Create a new marker object.
 

--- Updated File utils.py in package CMF --
--- utils.py	2001/04/10 17:23:48	1.8
+++ utils.py	2001/04/24 14:12:13	1.9
@@ -90,9 +90,14 @@
 import Globals
 from Acquisition import aq_get, aq_inner, aq_parent
 from string import split
+import os
+from Globals import package_home
 
 try: from OFS.ObjectManager import UNIQUE
 except ImportError: UNIQUE = 2
+
+
+_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
 
 
 # Tool for getting at Tools, meant to be modified as policies or Tool