Commit ce99e890 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 0585ee5a
...@@ -335,7 +335,7 @@ def ERP5Site_getPythonSourceCodeCompletionList(self, data, REQUEST=None): ...@@ -335,7 +335,7 @@ def ERP5Site_getPythonSourceCodeCompletionList(self, data, REQUEST=None):
else: else:
context_type = 'erp5.portal_type.{}'.format(context_type) 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( type_annotation = " # type: ({}) -> None".format(
', '.join([_guessType(part, context_type) for part in signature_parts])) ', '.join([_guessType(part, context_type) for part in signature_parts]))
body = "%s\ndef %s(%s):\n%s\n%s" % ( body = "%s\ndef %s(%s):\n%s\n%s" % (
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
const checker_parameters = { const checker_parameters = {
code: context.editor.getValue(), code: context.editor.getValue(),
portal_type: context.state.portal_type, portal_type: context.state.portal_type,
...(context.state.python_extra || {})
}; };
data.append('data', JSON.stringify(checker_parameters)); data.append('data', JSON.stringify(checker_parameters));
...@@ -174,6 +175,13 @@ ...@@ -174,6 +175,13 @@
options.portal_type === 'Module Component' options.portal_type === 'Module Component'
) { ) {
model_language = 'python'; 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.model_language = model_language;
state_dict.portal_type = options.portal_type; state_dict.portal_type = options.portal_type;
...@@ -354,8 +362,8 @@ ...@@ -354,8 +362,8 @@
line: position.lineNumber, line: position.lineNumber,
column: position.column, column: position.column,
}, },
...(gadget.state.python_extra || {})
}; };
data.append('data', JSON.stringify(complete_parameters)); data.append('data', JSON.stringify(complete_parameters));
return fetch( return fetch(
gadget.state.language_support_url + gadget.state.language_support_url +
...@@ -401,6 +409,7 @@ ...@@ -401,6 +409,7 @@
line: position.lineNumber, line: position.lineNumber,
column: position.column, column: position.column,
}, },
...(gadget.state.python_extra || {})
}; };
complete_parameters['xxx_definition'] = true; complete_parameters['xxx_definition'] = true;
data.append('data', JSON.stringify(complete_parameters)); data.append('data', JSON.stringify(complete_parameters));
......
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </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