Commit 3637e00d authored by Sebastien Robin's avatar Sebastien Robin

erp5_code_mirror: avoid multiple parallel code to check syntax on server side,...

erp5_code_mirror: avoid multiple parallel code to check syntax on server side, this avoid blocking all zope threads
parent a66cee44
...@@ -441,30 +441,40 @@ ...@@ -441,30 +441,40 @@
is_maximized = true;\n is_maximized = true;\n
}\n }\n
\n \n
var update_check_text = undefined,\n
update_check_running = false;\n
function checkPythonSourceCode(text, updateLinting, options, cm) {\n function checkPythonSourceCode(text, updateLinting, options, cm) {\n
update_check_text = text;\n
checker_parameters = {code: text};\n checker_parameters = {code: text};\n
<dtml-if bound_names>\n <dtml-if bound_names>\n
checker_parameters[\'bound_names\'] = <dtml-var name="bound_names">;\n checker_parameters[\'bound_names\'] = <dtml-var name="bound_names">;\n
checker_parameters[\'params\'] = $(\'input[name="params"]\').val();\n checker_parameters[\'params\'] = $(\'input[name="params"]\').val();\n
</dtml-if>\n </dtml-if>\n
$.post(\n if (update_check_running === false) {\n
\'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n update_check_running = true;\n
{\'data\': JSON.stringify(checker_parameters)},\n $.post(\n
function(data){\n \'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n
var messages = data.annotations;\n {\'data\': JSON.stringify(checker_parameters)},\n
var found = [];\n function(data){\n
for(var i = 0; i < messages.length; i++) {\n var messages = data.annotations;\n
message = messages[i];\n var found = [];\n
found.push({\n update_check_running = false;\n
from: CodeMirror.Pos(message.row, message.column - 1),\n for(var i = 0; i < messages.length; i++) {\n
to: CodeMirror.Pos(message.row, message.column),\n message = messages[i];\n
message: message.text,\n found.push({\n
severity: message.type\n from: CodeMirror.Pos(message.row, message.column - 1),\n
});\n to: CodeMirror.Pos(message.row, message.column),\n
}\n message: message.text,\n
\n severity: message.type\n
updateLinting(cm, found);\n });\n
});\n }\n
\n
updateLinting(cm, found);\n
if (update_check_text !== text) {\n
checkPythonSourceCode(update_check_text, updateLinting, options, cm);\n
}\n
});\n
}\n
}\n }\n
\n \n
var mode = "&dtml-mode;";\n var mode = "&dtml-mode;";\n
......
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