def setName(self, name=None): '''always ues this function to change the name of an nmpml object, to avoid generating non-unique names. If this function is called without arguments (or name is None), it will verify name uniqueness of the current name. Return value is the actual name that was set (which may be different than the provided argument do to required name uniqueness) Its a very good idea to call "update_refs" after calling this function, since it may break references ''' on=self.attributes['Name'] name=NmpmlObject.setName(self, name) cell=self.container if name==on and cell._sections.get(name)==self: return if cell._sections.has_key(on): del(cell._sections[on]) cell._sections[name]=self p = self.parent() if cell._children.has_key(p): if on in cell._children[p]: cell._children[p].remove(on) cell._children[p].add(name) else: cell._children[p]=set([name]) if cell._children.has_key(on): for c in cell._children[on]: c=cell._sections[c] c.attributes['Parent']=name cell._children[name]=cell._children[on] del(cell._children[on])