Commit 64bb960d authored by Jérome Perrin's avatar Jérome Perrin

ERP5 Python Scripts: fix setParameterSignature('')

programmatically calling script.setParameterSignature('') was
setting _params to None and making it causing errors when calling
the script
parent 472f5d8b
...@@ -114,10 +114,10 @@ class PythonScript(XMLObject, ZopePythonScript, ExpressionMixin('expression')): ...@@ -114,10 +114,10 @@ class PythonScript(XMLObject, ZopePythonScript, ExpressionMixin('expression')):
override to call ZopePythonScript methods to force compiling code override to call ZopePythonScript methods to force compiling code
and prevent setting to None and prevent setting to None
""" """
if value is None: if value:
self._params = ''
else:
self._baseSetParameterSignature(value) self._baseSetParameterSignature(value)
else:
self._params = ''
self._compile() self._compile()
def _setProxyRoleList(self, value): def _setProxyRoleList(self, value):
......
...@@ -55,6 +55,19 @@ class TestERP5PythonScript(ERP5TypeTestCase): ...@@ -55,6 +55,19 @@ class TestERP5PythonScript(ERP5TypeTestCase):
self.portal.portal_skins.custom.manage_delObjects([self.id()]) self.portal.portal_skins.custom.manage_delObjects([self.id()])
self.tic() self.tic()
def test_default_params(self):
self.assertEqual(self.script.getParameterSignature(), '')
def test_set_params(self):
self.script.setParameterSignature('foo')
self.assertEqual(self.script.getParameterSignature(), 'foo')
self.script.setParameterSignature('')
self.assertEqual(self.script.getParameterSignature(), '')
self.script.setParameterSignature('bar')
self.assertEqual(self.script.getParameterSignature(), 'bar')
self.script.setParameterSignature(None) # Base_edit calls with None
self.assertEqual(self.script.getParameterSignature(), '')
def test_manage_addPythonScriptThroughZMI(self): def test_manage_addPythonScriptThroughZMI(self):
resp = self.publish( resp = self.publish(
'/{}/portal_skins/manage_addProduct/ERP5/addPythonScriptThroughZMIForm'.format(self.portal.getId()), '/{}/portal_skins/manage_addProduct/ERP5/addPythonScriptThroughZMIForm'.format(self.portal.getId()),
......
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