Commit f35d8fdd authored by Jérome Perrin's avatar Jérome Perrin

WIP: support ERP5 Python Scripts with monaco/jedi XXX the current script I'm...

WIP: support ERP5 Python Scripts with monaco/jedi XXX the current script I'm editing is hardcoded :)
parent 07dece74
Pipeline #17624 passed with stage
in 0 seconds
......@@ -335,7 +335,7 @@ def ERP5Site_getPythonSourceCodeCompletionList(self, data, REQUEST=None):
else:
context_type = 'erp5.portal_type.{}'.format(context_type)
imports = "import erp5.portal_type; import Products.ERP5Type.Core.Folder; import ZPublisher.HTTPRequest; import Products.PythonScripts"
imports = "from typing import *; import erp5.portal_type; import Products.ERP5Type.Core.Folder; import ZPublisher.HTTPRequest; import Products.PythonScripts"
type_annotation = " # type: ({}) -> None".format(
', '.join([_guessType(part, context_type) for part in signature_parts]))
body = "%s\ndef %s(%s):\n%s\n%s" % (
......
......@@ -95,6 +95,7 @@
const checker_parameters = {
code: context.editor.getValue(),
portal_type: context.state.portal_type,
...(context.state.python_extra || {})
};
data.append('data', JSON.stringify(checker_parameters));
......@@ -174,6 +175,13 @@
options.portal_type === 'Module Component'
) {
model_language = 'python';
if (options.portal_type === 'Python Script' || options.portal_type === 'Workflow Script') {
state_dict.python_extra = {
'script_name': 'ERP5Site_importEkihoComponentSpreadsheet',
'bound_names': ["context", "container", "script", "traverse_subpath", "printed", "same_type", "string", "sequence", "random", "DateTime", "whrandom", "reorder", "sets", "test", "math"],
'params': []
}
}
}
state_dict.model_language = model_language;
state_dict.portal_type = options.portal_type;
......@@ -354,8 +362,8 @@
line: position.lineNumber,
column: position.column,
},
...(gadget.state.python_extra || {})
};
data.append('data', JSON.stringify(complete_parameters));
return fetch(
gadget.state.language_support_url +
......@@ -401,6 +409,7 @@
line: position.lineNumber,
column: position.column,
},
...(gadget.state.python_extra || {})
};
complete_parameters['xxx_definition'] = true;
data.append('data', JSON.stringify(complete_parameters));
......
......@@ -135,7 +135,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'editor\', context.getPortalObject().portal_preferences.getPreferredSourceCodeEditor(\'text_area\')), (\'portal_type\', context.getPortalType()), (\'maximize\', \'listbox\' not in field.id), (\'content_type\', context.getProperty(\'content_type\'))]</string> </value>
<value> <string>python: [(\'editor\', context.getPortalObject().portal_preferences.getPreferredSourceCodeEditor(\'text_area\')), (\'portal_type\', context.getPortalType()), (\'maximize\', \'listbox\' not in field.id), (\'content_type\', context.getProperty(\'content_type\')), (\'language_support_url\', context.getPortalObject().portal_url())]</string> </value>
</item>
</dictionary>
</pickle>
......
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