# HG changeset patch # User Edouard Tisserant # Date 1604310969 -3600 # Node ID 7ab2b5a18e65fd70893535df877d25074e0acdf7 # Parent d4bede6cd3f1fef9857d141d46b45ecb09d3ce4e Allow customization of generated py_ext OnChange calls, by adding a static method to PythonFileCTNMixin that can the be later hot patched. diff -r d4bede6cd3f1 -r 7ab2b5a18e65 py_ext/PythonFileCTNMixin.py --- a/py_ext/PythonFileCTNMixin.py Tue Oct 20 00:23:52 2020 +0200 +++ b/py_ext/PythonFileCTNMixin.py Mon Nov 02 10:56:09 2020 +0100 @@ -36,6 +36,8 @@ from py_ext.PythonEditor import PythonEditor + + class PythonFileCTNMixin(CodeFile): CODEFILE_NAME = "PyFile" @@ -105,6 +107,14 @@ ret.append(("On_"+location_str+"_Change", "python_poll", "")) return ret + @staticmethod + def GetVarOnChangeContent(var): + """ + returns given variable onchange field + function is meant to allow customization + """ + return var.getonchange() + def CTNGenerate_C(self, buildpath, locations): # location string for that CTN location_str = "_".join(map(str, self.GetCurrentLocation())) @@ -112,11 +122,11 @@ def _onchangecode(var): return [onchangecall.strip() + "('" + var.getname() + "')" - for onchangecall in var.getonchange().split(',')] + for onchangecall in self.GetVarOnChangeContent(var).split(',')] def _onchange(var): - return repr(var.getonchange()) \ - if var.getonchange() else None + content = self.GetVarOnChangeContent(var) + return repr(content) if content else None pyextname = self.CTNName() varinfos = map(