diff --git a/bt5/erp5_administration/ExtensionTemplateItem/portal_components/extension.erp5.ERP5Administration.py b/bt5/erp5_administration/ExtensionTemplateItem/portal_components/extension.erp5.ERP5Administration.py index 809d83e2714c920f8143120ae5a6704bfedf86c1..be82c968cf78818a1ff1803ef3b8eb1ea6217582 100644 --- a/bt5/erp5_administration/ExtensionTemplateItem/portal_components/extension.erp5.ERP5Administration.py +++ b/bt5/erp5_administration/ExtensionTemplateItem/portal_components/extension.erp5.ERP5Administration.py @@ -173,52 +173,6 @@ def checkConversionToolAvailability(self): result.edit(severity=severity) active_process.postResult(result) -from Products.ERP5Type.Utils import checkPythonSourceCode - -def checkPythonSourceCodeAsJSON(self, data, REQUEST=None): - """ - Check Python source suitable for Source Code Editor and return a JSON object - """ - import json - - # XXX data is encoded as json, because jQuery serialize lists as [] - if isinstance(data, basestring): - data = json.loads(data) - - # data contains the code, the bound names and the script params. From this - # we reconstruct a function that can be checked - def indent(text): - return ''.join((" " + line) for line in text.splitlines(True)) - - is_python_script = 'bound_names' in data - if is_python_script: - signature_parts = data['bound_names'] - if data['params']: - signature_parts += [data['params']] - signature = ", ".join(signature_parts) - - function_name = "function_name" - body = "def %s(%s):\n%s" % (function_name, - signature, - indent(data['code']) or " pass") - else: - body = data['code'] - - message_list = checkPythonSourceCode(body.encode('utf8'), data.get('portal_type')) - for message_dict in message_list: - if is_python_script: - message_dict['row'] = message_dict['row'] - 2 - else: - message_dict['row'] = message_dict['row'] - 1 - - if message_dict['type'] in ('E', 'F'): - message_dict['type'] = 'error' - else: - message_dict['type'] = 'warning' - - if REQUEST is not None: - REQUEST.RESPONSE.setHeader('content-type', 'application/json') - return json.dumps(dict(annotations=message_list)) def filterSecurityUidDict(security_uid_dict, referenced_security_uid_set): """ diff --git a/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.py b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb541721ef88eff911fffcddff014fe63b10c369 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.py @@ -0,0 +1,46 @@ +import json +from Products.ERP5Type.Utils import checkPythonSourceCode + +def checkPythonSourceCodeAsJSON(self, data, REQUEST=None): + """ + Check Python source suitable for Source Code Editor and return a JSON object + """ + + # XXX data is encoded as json, because jQuery serialize lists as [] + if isinstance(data, basestring): + data = json.loads(data) + + # data contains the code, the bound names and the script params. From this + # we reconstruct a function that can be checked + def indent(text): + return ''.join((" " + line) for line in text.splitlines(True)) + + is_python_script = 'bound_names' in data + if is_python_script: + signature_parts = data['bound_names'] + if data['params']: + signature_parts += [data['params']] + signature = ", ".join(signature_parts) + + function_name = "function_name" + body = "def %s(%s):\n%s" % (function_name, + signature, + indent(data['code']) or " pass") + else: + body = data['code'] + + message_list = checkPythonSourceCode(body.encode('utf8'), data.get('portal_type')) + for message_dict in message_list: + if is_python_script: + message_dict['row'] = message_dict['row'] - 2 + else: + message_dict['row'] = message_dict['row'] - 1 + + if message_dict['type'] in ('E', 'F'): + message_dict['type'] = 'error' + else: + message_dict['type'] = 'warning' + + if REQUEST is not None: + REQUEST.RESPONSE.setHeader('content-type', 'application/json') + return json.dumps(dict(annotations=message_list)) diff --git a/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.xml b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5b10bb711c37d617f5aeb68b3ba7e3a3c53f84f --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.xml @@ -0,0 +1,127 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Extension Component" module="erp5.portal_type"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_recorded_property_dict</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>default_reference</string> </key> + <value> <string>PythonCodeUtils</string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>extension.erp5.PythonCodeUtils</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Extension Component</string> </value> + </item> + <item> + <key> <string>sid</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>text_content_error_message</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>text_content_warning_message</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>version</string> </key> + <value> <string>erp5</string> </value> + </item> + <item> + <key> <string>workflow_history</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary> + <item> + <key> <string>component_validation_workflow</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> + </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="4" aka="AAAAAAAAAAQ="> + <pickle> + <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_log</string> </key> + <value> + <list> + <dictionary> + <item> + <key> <string>action</string> </key> + <value> <string>validate</string> </value> + </item> + <item> + <key> <string>validation_state</string> </key> + <value> <string>validated</string> </value> + </item> + </dictionary> + </list> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getModifiableFieldList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiableFieldList.py similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getModifiableFieldList.py rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiableFieldList.py diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getModifiableFieldList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiableFieldList.xml similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getModifiableFieldList.xml rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getModifiableFieldList.xml diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getPythonSourceCodeMessageList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getPythonSourceCodeMessageList.py similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getPythonSourceCodeMessageList.py rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getPythonSourceCodeMessageList.py diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getPythonSourceCodeMessageList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getPythonSourceCodeMessageList.xml similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/BusinessTemplate_getPythonSourceCodeMessageList.xml rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_getPythonSourceCodeMessageList.xml diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/ERP5Site_checkPythonSourceCodeAsJSON.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_checkPythonSourceCodeAsJSON.xml similarity index 92% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/ERP5Site_checkPythonSourceCodeAsJSON.xml rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_checkPythonSourceCodeAsJSON.xml index 58b2720f5194089c8208482024b9f0fc576622d8..10105de7911fc0e264aa6f51d80ebfc96ddaf39c 100644 --- a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/ERP5Site_checkPythonSourceCodeAsJSON.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_checkPythonSourceCodeAsJSON.xml @@ -12,7 +12,7 @@ </item> <item> <key> <string>_module</string> </key> - <value> <string>ERP5Administration</string> </value> + <value> <string>PythonCodeUtils</string> </value> </item> <item> <key> <string>id</string> </key> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkDuplicateSelectionName.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkDuplicateSelectionName.py similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkDuplicateSelectionName.py rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkDuplicateSelectionName.py diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkDuplicateSelectionName.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkDuplicateSelectionName.xml similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkDuplicateSelectionName.xml rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkDuplicateSelectionName.xml diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkFieldExternalValidator.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.py similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkFieldExternalValidator.py rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.py diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkFieldExternalValidator.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.xml similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_checkFieldExternalValidator.xml rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.xml diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_getDuplicateSelectionNameDict.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_getDuplicateSelectionNameDict.py similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_getDuplicateSelectionNameDict.py rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_getDuplicateSelectionNameDict.py diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_getDuplicateSelectionNameDict.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_getDuplicateSelectionNameDict.xml similarity index 100% rename from bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/SkinsTool_getDuplicateSelectionNameDict.xml rename to product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_getDuplicateSelectionNameDict.xml diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_extension_id_list b/product/ERP5/bootstrap/erp5_core/bt/template_extension_id_list index d76e0a572064afd026c1818b7999afa14785c7c7..3dd440330bcc353c19b451265dd2fc943f87a675 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_extension_id_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_extension_id_list @@ -3,4 +3,5 @@ extension.erp5.InventoryBrain extension.erp5.SearchUtility extension.erp5.StandardSecurity extension.erp5.ZODBHistory -extension.erp5.FolderWorkflowActionUtils \ No newline at end of file +extension.erp5.FolderWorkflowActionUtils +extension.erp5.PythonCodeUtils \ No newline at end of file