Commit 6500889f authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Through Publisher, ExternalMethod getFuncCode() failed in

development mode because there was a check whether Extension on FS should be
reloaded even for Components.
parent 95bb2d37
......@@ -43,6 +43,18 @@ if 1:
ExternalMethod.getFunction = getFunction
ExternalMethod_reloadIfChanged = ExternalMethod.reloadIfChanged
def reloadIfChanged(self):
try:
component_module = __import__(
'erp5.component.extension.' + self._module,
fromlist=['erp5.component.extension'],
level=0)
except ImportError:
return ExternalMethod_reloadIfChanged(self)
ExternalMethod.reloadIfChanged = reloadIfChanged
def __call__(self, *args, **kw):
"""Call an ExternalMethod
......
......@@ -1834,6 +1834,19 @@ class TestZodbExtensionComponent(_TestZodbComponent):
external_method = self.getPortal().TestExternalMethod
self.assertEqual(external_method(), 42)
# Check that the External Method returns expected result through Publisher
# with or without DevelopmentMode
path = '%s/TestExternalMethod' % self.portal.getId()
self.assertEqual(self.publish(path).getBody(), '42')
import Globals
previous_development_mode = Globals.DevelopmentMode
Globals.DevelopmentMode = not Globals.DevelopmentMode
try:
self.assertEqual(self.publish(path).getBody(), '42')
finally:
Globals.DevelopmentMode = previous_development_mode
# Add a Python Script with the External Method defined above and check
# that it returns 42
from Products.PythonScripts.PythonScript import manage_addPythonScript
......
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