[Zope-Checkins] CVS: Zope/lib/python/Products/ExternalMethod - ExternalMethod.py:1.48.10.1
Matt Behrens
matt@zigg.com
Wed, 29 May 2002 15:45:52 -0400
Update of /cvs-repository/Zope/lib/python/Products/ExternalMethod
In directory cvs.zope.org:/tmp/cvs-serv18366/lib/python/Products/ExternalMethod
Modified Files:
Tag: zigg_unix-install-control-config-branch
ExternalMethod.py
Log Message:
Merge in HEAD (except setup.py... gotta chat about that one) :-)
=== Zope/lib/python/Products/ExternalMethod/ExternalMethod.py 1.48 => 1.48.10.1 ===
meta_type = 'External Method'
- func_defaults = ComputedAttribute(lambda self: self._v_func_defaults)
- func_code = ComputedAttribute(lambda self: self._v_func_code)
+ func_defaults = ComputedAttribute(lambda self: self.getFuncDefaults())
+ func_code = ComputedAttribute(lambda self: self.getFuncCode())
+
ZopeTime=Acquisition.Acquired
HelpSys=Acquisition.Acquired
@@ -141,12 +142,43 @@
self._v_func_defaults = ff.func_defaults
self._v_func_code = FuncCode(ff,f is not ff)
-
+
self._v_f=f
return f
-
+ def reloadIfChanged(self):
+ # If the file has been modified since last loaded, force a reload.
+ ts=os.stat(self.filepath())[stat.ST_MTIME]
+ if (not hasattr(self, '_v_last_read') or
+ (ts != self._v_last_read)):
+ self._v_f=self.getFunction(1)
+ self._v_last_read=ts
+
+ if DevelopmentMode:
+ # In development mode we do an automatic reload
+ # if the module code changed
+ def getFuncDefaults(self):
+ self.reloadIfChanged()
+ if not hasattr(self, '_v_func_defaults'):
+ self._v_f = self.getFunction()
+ return self._v_func_defaults
+
+ def getFuncCode(self):
+ self.reloadIfChanged()
+ if not hasattr(self, '_v_func_code'):
+ self._v_f = self.getFunction()
+ return self._v_func_code
+ else:
+ def getFuncDefaults(self):
+ if not hasattr(self, '_v_func_defaults'):
+ self._v_f = self.getFunction()
+ return self._v_func_defaults
+
+ def getFuncCode(self):
+ if not hasattr(self, '_v_func_code'):
+ self._v_f = self.getFunction()
+ return self._v_func_code
def __call__(self, *args, **kw):
"""Call an ExternalMethod
@@ -178,14 +210,8 @@
"external method could not be called " \
"because the file does not exist"
-
if DevelopmentMode:
- # If the file has been modified since last loaded, force a reload.
- ts=os.stat(self.filepath())[stat.ST_MTIME]
- if (not hasattr(self, '_v_last_read') or
- (ts != self._v_last_read)):
- self._v_f=self.getFunction(1)
- self._v_last_read=ts
+ self.reloadIfChanged()
if hasattr(self, '_v_f'):
f=self._v_f