(self, from_search_type, to_search_type, mode='remove', commit=True)
edit the connection im a schema
edit the connection im a schema
edit the connection im a schema
def edit_connection(self, from_search_type, to_search_type, mode='remove', commit=True):
        '''edit the connection im a schema'''
        xpath = "schema/connect[@from='%s' and @to='%s']" %(from_search_type, to_search_type)

        node = self.xml.get_node(xpath)
        schema_node = self.xml.get_node("schema")
        if node is not None:
            if mode == 'remove':
                #schema_node.removeChild(node)
                self.xml.remove_child(schema_node, node)
        else:
            # add only if it does not exist
            if mode == 'add':
                connect_node = self.xml.create_element("connect")
                self.xml.set_attribute(connect_node, "from", from_search_type)
                self.xml.set_attribute(connect_node, "to", to_search_type)
                self.xml.set_attribute(connect_node, "relationship", 'code')
                self.xml.set_attribute(connect_node, "type", 'hierarchy')
                #schema_node.appendChild(connect_node)
                self.xml.append_child(schema_node, connect_node)

               
        if commit:
            self.set_value("schema", self.xml.to_string() )
def edit_connection ( self , from_search_type , to_search_type , mode = 'remove' , commit = True ) : xpath = "schema/connect[@from='%s' and @to='%s']" % ( from_search_type , to_search_type ) node = self . xml . get_node ( xpath ) schema_node = self . xml . get_node ( "schema" ) if node is not None : if mode == 'remove' : #schema_node.removeChild(node) self . xml . remove_child ( schema_node , node ) else : # add only if it does not exist if mode == 'add' : connect_node = self . xml . create_element ( "connect" ) self . xml . set_attribute ( connect_node , "from" , from_search_type ) self . xml . set_attribute ( connect_node , "to" , to_search_type ) self . xml . set_attribute ( connect_node , "relationship" , 'code' ) self . xml . set_attribute ( connect_node , "type" , 'hierarchy' ) #schema_node.appendChild(connect_node) self . xml . append_child ( schema_node , connect_node ) if commit : self . set_value ( "schema" , self . xml . to_string ( ) )