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,18 +441,24 @@ ...@@ -441,18 +441,24 @@
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
if (update_check_running === false) {\n
update_check_running = true;\n
$.post(\n $.post(\n
\'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n \'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n
{\'data\': JSON.stringify(checker_parameters)},\n {\'data\': JSON.stringify(checker_parameters)},\n
function(data){\n function(data){\n
var messages = data.annotations;\n var messages = data.annotations;\n
var found = [];\n var found = [];\n
update_check_running = false;\n
for(var i = 0; i < messages.length; i++) {\n for(var i = 0; i < messages.length; i++) {\n
message = messages[i];\n message = messages[i];\n
found.push({\n found.push({\n
...@@ -464,8 +470,12 @@ ...@@ -464,8 +470,12 @@
}\n }\n
\n \n
updateLinting(cm, found);\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 \n
var mode = "&dtml-mode;";\n var mode = "&dtml-mode;";\n
if ( mode === "sql" ) {\n if ( mode === "sql" ) {\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