[CMF-checkins] CVS: CMF/CMFCore - FSObject.py:1.8.24.1 FSPageTemplate.py:1.3.20.1 FSPythonScript.py:1.14.24.1
Shane Hathaway
shane@cvs.zope.org
Wed, 23 Jan 2002 18:31:42 -0500
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv6554
Modified Files:
Tag: cmf-pre-1_3-branch
FSObject.py FSPageTemplate.py FSPythonScript.py
Log Message:
Delay parsing of FSPythonScripts and FSPageTemplates. It's very hard to get
this right because of the lack of interfaces, but it seems to work for now.
This makes CMF-enabled Zope sites start quickly again.
=== CMF/CMFCore/FSObject.py 1.8 => 1.8.24.1 ===
_file_mod_time = 0
+ _parsed = 0
def __init__(self, id, filepath, fullname=None, properties=None):
if properties:
@@ -92,11 +93,13 @@
# Refresh our contents from the filesystem if that is newer and we are
# running in debug mode.
def _updateFromFS(self):
- if Globals.DevelopmentMode:
+ parsed = self._parsed
+ if not parsed or Globals.DevelopmentMode:
fp = expandpath(self._filepath)
try: mtime=stat(fp)[8]
except: mtime=0
- if mtime != self._file_mod_time:
+ if not parsed or mtime != self._file_mod_time:
+ self._parsed = 1
self._file_mod_time = mtime
self._readFile(1)
=== CMF/CMFCore/FSPageTemplate.py 1.3 => 1.3.20.1 ===
try: data = file.read()
finally: file.close()
- self.write(data)
+ if reparse:
+ self.write(data)
security.declarePrivate('read')
def read(self):
=== CMF/CMFCore/FSPythonScript.py 1.14 => 1.14.24.1 ===
try: data = file.read()
finally: file.close()
- self._write(data, reparse)
+ if reparse:
+ self._write(data, reparse)
def _validateProxy(self, roles=None):
pass
+ def __render_with_namespace__(self, namespace):
+ '''Calls the script.'''
+ self._updateFromFS()
+ return Script.__render_with_namespace__(self, namespace)
+
+ def __call__(self, *args, **kw):
+ '''Calls the script.'''
+ self._updateFromFS()
+ return Script.__call__(self, args, kw)
+
#### The following is mainly taken from PythonScript.py ###
def _exec(self, bound_names, args, kw):
@@ -83,15 +94,11 @@
Calling a Python Script is an actual function invocation.
"""
- self._updateFromFS()
# Prepare the function.
f = self._v_f
if f is None:
- # Not yet compiled.
- self._write(self._source, 1)
- f = self._v_f
- if f is None:
- raise RuntimeError, '%s has errors.' % self._filepath
+ # The script has errors.
+ raise RuntimeError, '%s has errors.' % self._filepath
__traceback_info__ = bound_names, args, kw, self.func_defaults
@@ -185,15 +192,21 @@
# This ensures func_code and func_defaults are
# set when the code hasn't been compiled yet,
# just in time for mapply(). Truly odd, but so is mapply(). :P
- self._write(self._source, 1)
+ self._updateFromFS()
return self.__dict__.get('func_defaults', None)
func_defaults = ComputedAttribute(func_defaults, 1)
def func_code(self):
# See func_defaults.
- self._write(self._source, 1)
+ self._updateFromFS()
return self.__dict__.get('func_code', None)
func_code = ComputedAttribute(func_code, 1)
+
+ def title(self):
+ # See func_defaults.
+ self._updateFromFS()
+ return self.__dict__.get('title', None)
+ title = ComputedAttribute(title, 1)
Globals.InitializeClass(FSPythonScript)