# HG changeset patch # User Edouard Tisserant # Date 1604310969 -3600 # Node ID 013374b6cdb97395530668ea6abd3b355ac7172c # Parent a9b03c2634c56c0d9fa73ac72a1457ecb2101108 Allow customization of generated py_ext OnChange calls, by adding a static method to PythonFileCTNMixin that can the be later hot patched. diff -r a9b03c2634c5 -r 013374b6cdb9 py_ext/PythonFileCTNMixin.py --- a/py_ext/PythonFileCTNMixin.py Wed Oct 28 18:21:12 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(