Allow customization of generated py_ext OnChange calls, by adding a static method to PythonFileCTNMixin that can the be later hot patched.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 02 Nov 2020 10:56:09 +0100
changeset 2693 7ab2b5a18e65
parent 2692 d4bede6cd3f1
child 2694 3225990eb33e
Allow customization of generated py_ext OnChange calls, by adding a static method to PythonFileCTNMixin that can the be later hot patched.
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(