+ def saveAlternatives(self):
+ doc = xml.dom.minidom.Document()
+ root_element = doc.createElement('alternatives')
+ doc.appendChild(root_element)
+ root_element.appendChild(doc.createTextNode("\n"))
+
+ for alternative in self.alternatives.keys():
+ t = doc.createTextNode("\t")
+ root_element.appendChild(t)
+ t = doc.createElement('service')
+ t.setAttribute("ref", alternative)
+ root_element.appendChild(t)
+ t.appendChild(doc.createTextNode("\n"))
+ for x in self.alternatives[alternative]:
+ t.appendChild(doc.createTextNode("\t\t"))
+ l = doc.createElement('alternative')
+ l.setAttribute("ref", str(x))
+ t.appendChild(l)
+ t.appendChild(doc.createTextNode("\n"))
+ t.appendChild(doc.createTextNode("\t"))
+ root_element.appendChild(t)
+ t = doc.createTextNode("\n")
+ root_element.appendChild(t)
+ file = open(self.filename, "w")
+ doc.writexml(file)
+ file.write("\n")
+ file.close()
+
+ def loadAlternatives(self):
+ self.alternatives = {}
+ alternatives = {}
+ doc = xml.dom.minidom.parse(self.filename)
+
+ root = doc.childNodes[0]
+ for service in elementsWithTag(root.childNodes, 'service'):
+ newService = str(service.getAttribute('ref'))
+ if not self.alternatives.has_key(newService):
+ self.alternatives[newService] = []
+ for alternative in elementsWithTag(service.childNodes, 'alternative'):
+ newAlternative = str(alternative.getAttribute('ref'))
+ self.alternatives[newService].append(newAlternative)
+ addAlternative(newService, newAlternative)
+