Let extensions know when configuration is new, to apply defaults.
authorEdouard Tisserant <edouard@beremiz.fr>
Tue, 21 Jan 2025 09:29:59 +0100 (7 weeks ago)
changeset 4098 8c12c0df026a
parent 4097 08ab4ad50346
child 4099 97e93962be0c
Let extensions know when configuration is new, to apply defaults.

Add "new_config" member to CTN, True when config was just created.
ConfigTreeNode.py
--- a/ConfigTreeNode.py	Thu Jan 16 15:30:35 2025 +0100
+++ b/ConfigTreeNode.py	Tue Jan 21 09:29:59 2025 +0100
@@ -585,6 +585,8 @@
                 NewCTNName = self.FindNewName(CTNName)
                 # If dir have already be made, and file exist
                 if os.path.isdir(self.CTNPath(NewCTNName)):  # and os.path.isfile(self.ConfNodeXmlFilePath(CTNName)):
+                    # Make CTN aware that this configuration was loaded
+                    self.new_config = False
                     # Load the confnode.xml file into parameters members
                     self.LoadXMLParams(NewCTNName)
                     # Basic check. Better to fail immediately.
@@ -605,6 +607,8 @@
                     # just loaded, nothing to saved
                     self.ChangesToSave = False
                 else:
+                    # Make CTN aware that this is first time configuration
+                    self.new_config = True
                     # If confnode do not have corresponding file/dirs - they will be created on Save
                     self.CTNMakeDir()
                     # Find an IEC number