equal
deleted
inserted
replaced
71 return os.path.join(self.CTNPath(CTNName), "confnode.xml") |
71 return os.path.join(self.CTNPath(CTNName), "confnode.xml") |
72 |
72 |
73 def ConfNodePath(self): |
73 def ConfNodePath(self): |
74 return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType) |
74 return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType) |
75 |
75 |
76 def CTNPath(self,CTNName=None): |
76 def CTNPath(self,CTNName=None,project_path=None): |
77 if not CTNName: |
77 if not CTNName: |
78 CTNName = self.CTNName() |
78 CTNName = self.CTNName() |
79 return os.path.join(self.CTNParent.CTNPath(), |
79 if not project_path: |
|
80 project_path = self.CTNParent.CTNPath() |
|
81 return os.path.join(project_path, |
80 CTNName + NameTypeSeparator + self.CTNType) |
82 CTNName + NameTypeSeparator + self.CTNType) |
81 |
83 |
82 def CTNName(self): |
84 def CTNName(self): |
83 return self.BaseParams.getName() |
85 return self.BaseParams.getName() |
84 |
86 |
111 return False |
113 return False |
112 |
114 |
113 def RemoteExec(self, script, **kwargs): |
115 def RemoteExec(self, script, **kwargs): |
114 return self.CTNParent.RemoteExec(script, **kwargs) |
116 return self.CTNParent.RemoteExec(script, **kwargs) |
115 |
117 |
116 def OnCTNSave(self): |
118 def OnCTNSave(self, from_project_path=None): |
117 #Default, do nothing and return success |
119 #Default, do nothing and return success |
118 return True |
120 return True |
119 |
121 |
120 def GetParamsAttributes(self, path = None): |
122 def GetParamsAttributes(self, path = None): |
121 if path: |
123 if path: |
153 return value, False |
155 return value, False |
154 |
156 |
155 def CTNMakeDir(self): |
157 def CTNMakeDir(self): |
156 os.mkdir(self.CTNPath()) |
158 os.mkdir(self.CTNPath()) |
157 |
159 |
158 def CTNRequestSave(self): |
160 def CTNRequestSave(self, from_project_path=None): |
159 if self.GetCTRoot().CheckProjectPathPerm(False): |
161 if self.GetCTRoot().CheckProjectPathPerm(False): |
160 # If confnode do not have corresponding directory |
162 # If confnode do not have corresponding directory |
161 ctnpath = self.CTNPath() |
163 ctnpath = self.CTNPath() |
162 if not os.path.isdir(ctnpath): |
164 if not os.path.isdir(ctnpath): |
163 # Create it |
165 # Create it |
176 XMLFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") |
178 XMLFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") |
177 XMLFile.write(self.CTNParams[1].generateXMLText(self.CTNParams[0], 0).encode("utf-8")) |
179 XMLFile.write(self.CTNParams[1].generateXMLText(self.CTNParams[0], 0).encode("utf-8")) |
178 XMLFile.close() |
180 XMLFile.close() |
179 |
181 |
180 # Call the confnode specific OnCTNSave method |
182 # Call the confnode specific OnCTNSave method |
181 result = self.OnCTNSave() |
183 result = self.OnCTNSave(from_project_path) |
182 if not result: |
184 if not result: |
183 return _("Error while saving \"%s\"\n")%self.CTNPath() |
185 return _("Error while saving \"%s\"\n")%self.CTNPath() |
184 |
186 |
185 # mark confnode as saved |
187 # mark confnode as saved |
186 self.ChangesToSave = False |
188 self.ChangesToSave = False |
187 # go through all children and do the same |
189 # go through all children and do the same |
188 for CTNChild in self.IterChildren(): |
190 for CTNChild in self.IterChildren(): |
189 result = CTNChild.CTNRequestSave() |
191 result = CTNChild.CTNRequestSave( |
|
192 CTNChild.CTNPath(project_path=from_project_path)) |
190 if result: |
193 if result: |
191 return result |
194 return result |
192 return None |
195 return None |
193 |
196 |
194 def CTNImport(self, src_CTNPath): |
197 def CTNImport(self, src_CTNPath): |