Commit b3a20523 authored by Ken Manheimer's avatar Ken Manheimer

ExternalMethod.__call__(): Fixed DevelopmentMode behavior so it didn't

reload extenal method files every time.

The problem was that the entire os.stat() record was being compared,
and that includes the access time, which of course changes every time
the method is loaded - self fulfilling prophecy, and all.

Instead, we now just stash and compare the modification time
(ST_MTIME) field, and get rid of the extraneous (expensive) reloads.
parent 922f6682
...@@ -88,12 +88,12 @@ ...@@ -88,12 +88,12 @@
This product provides support for external methods, which allow This product provides support for external methods, which allow
domain-specific customization of web environments. domain-specific customization of web environments.
""" """
__version__='$Revision: 1.31 $'[11:-2] __version__='$Revision: 1.32 $'[11:-2]
from Acquisition import Explicit from Acquisition import Explicit
from Globals import Persistent, HTMLFile, MessageDialog, HTML from Globals import Persistent, HTMLFile, MessageDialog, HTML
import OFS.SimpleItem import OFS.SimpleItem
from string import split, join, find, lower from string import split, join, find, lower
import AccessControl.Role, sys, os, traceback import AccessControl.Role, sys, os, stat, traceback
from OFS.SimpleItem import pretty_tb from OFS.SimpleItem import pretty_tb
from App.Extensions import getObject, getPath, FuncCode from App.Extensions import getObject, getPath, FuncCode
from Globals import DevelopmentMode from Globals import DevelopmentMode
...@@ -231,9 +231,10 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Explicit, ...@@ -231,9 +231,10 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Explicit,
""" """
if DevelopmentMode: if DevelopmentMode:
ts=os.stat(self.filepath()) # If the file has been modified since last loaded, force a reload.
if not hasattr(self, '_v_last_read') or \ ts=os.stat(self.filepath())[stat.ST_MTIME]
(ts != self._v_last_read): if (not hasattr(self, '_v_last_read') or
(ts != self._v_last_read)):
self._v_f=self.getFunction(1,1) self._v_f=self.getFunction(1,1)
self._v_last_read=ts self._v_last_read=ts
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment