From d2281edde8eef83ed7a9f6d4c45a67135e90ac25 Mon Sep 17 00:00:00 2001
From: Wenjie Zheng <wenjie.zheng@tiolive.com>
Date: Tue, 10 Feb 2015 12:08:47 +0000
Subject: [PATCH] PythonScript.py: Delete _params if it's an empty string, to
 avoid NoneType parameters from generating.

---
 product/ERP5/Document/PythonScript.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/Document/PythonScript.py b/product/ERP5/Document/PythonScript.py
index ae7cf2b8a5..c19e4e3d4e 100644
--- a/product/ERP5/Document/PythonScript.py
+++ b/product/ERP5/Document/PythonScript.py
@@ -2,7 +2,7 @@
 #
 # Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
 #                    Sebastien Robin <seb@nexedi.com>
-#
+#                    Wenjie Zheng <wenjie.zheng@tiolive.com>
 # WARNING: This program as such is intended to be used by professional
 # programmers who take the whole responsability of assessing all potential
 # consequences resulting from its eventual inadequacies and bugs
@@ -27,7 +27,7 @@
 ##############################################################################
 
 from AccessControl import ClassSecurityInfo
-
+from AccessControl.class_init import InitializeClass
 from Products.ERP5Type import Permissions, PropertySheet
 from App.special_dtml import HTMLFile
 from Products.ERP5Type.XMLObject import XMLObject
@@ -109,7 +109,12 @@ class PythonScript(XMLObject, ZopePythonScript):
       """
       override to call ZopePythonScript methods to force compiling code
       """
+      if value is None:
+        value = ''
       self._baseSetParameterSignature(value)
+      if self._params is None or '':
+        ### zwj: avoid NoneType parameters from generating in ZHtml edit page
+        delattr(self, "_params")
       self._compile()
 
     def _setProxyRoleList(self, value):
@@ -127,3 +132,5 @@ class PythonScript(XMLObject, ZopePythonScript):
     # We need to take __setstate__ from ZopePythonScript in order to
     # generate _v_ft attributes which is necessary to run the script
     __setstate__ = ZopePythonScript.__setstate__
+
+InitializeClass(PythonScript)
\ No newline at end of file
-- 
2.30.9