def _handle_apply(self, kwargs): if kwargs['filename'] == self.filename and kwargs['id_'] == self.id_ \ and self._is_modified(): core_api.update_item_text(self.filename, self.id_, self.area.GetValue(), kwargs['group'], kwargs['description']) self._refresh_mod_state()
def upsert_link(filename, id_, target, group, description='Insert link'): # target could be None (creating a broken link) or could be a no-longer # existing item if core_api.is_item(filename, target): # Forbid circular links (including links to self), as it could generate # unexpected infinite recursions (e.g. with synchronize_links_text) if id_ in find_links_chain(filename, target): raise exceptions.CircularLinksError() else: # Sync text tgttext = core_api.get_item_text(filename, target) core_api.update_item_text(filename, id_, tgttext, group=group, description=description) # Drop any rules if organism_api and filename in \ organism_api.get_supported_open_databases(): organism_api.update_item_rules(filename, id_, [], group=group, description=description) else: # Force target = None if the given target no longer exists target = None # Drop any rules if organism_api and filename in \ organism_api.get_supported_open_databases(): organism_api.update_item_rules(filename, id_, [], group=group, description=description) # Note that exceptions.CircularLinksError could be raised before getting # here qconn = core_api.get_connection(filename) cursor = qconn.cursor() cursor.execute(queries.links_select_id, (id_, )) res = cursor.fetchone() # Do not allow creating more than one link per item if res: oldtarget = res['L_target'] do_update_link(filename, cursor, target, id_) core_api.give_connection(filename, qconn) core_api.insert_history(filename, group, id_, 'link_update', description, str(target) if target is not None else None, oldtarget if str(oldtarget) is not None else None) else: oldtarget = False # 'target' can be None, thus allowing the creation of a broken link do_insert_link(filename, cursor, id_, target) core_api.give_connection(filename, qconn) core_api.insert_history(filename, group, id_, 'link_insert', description, str(target) if target is not None else None, None) upsert_link_event.signal(filename=filename, id_=id_, target=target, oldtarget=oldtarget)
def synchronize_links_text(filename, target, text, group, description): if filename in cdbs: for id_ in find_back_links(filename, target): core_api.update_item_text(filename, id_, text, group, description)
def upsert_link(filename, id_, target, group, description='Insert link'): # target could be None (creating a broken link) or could be a no-longer # existing item if core_api.is_item(filename, target): # Forbid circular links (including links to self), as it could generate # unexpected infinite recursions (e.g. with synchronize_links_text) if id_ in find_links_chain(filename, target): raise exceptions.CircularLinksError() else: # Sync text tgttext = core_api.get_item_text(filename, target) core_api.update_item_text(filename, id_, tgttext, group=group, description=description) # Drop any rules if organism_api and filename in \ organism_api.get_supported_open_databases(): organism_api.update_item_rules(filename, id_, [], group=group, description=description) else: # Force target = None if the given target no longer exists target = None # Drop any rules if organism_api and filename in \ organism_api.get_supported_open_databases(): organism_api.update_item_rules(filename, id_, [], group=group, description=description) # Note that exceptions.CircularLinksError could be raised before getting # here qconn = core_api.get_connection(filename) cursor = qconn.cursor() cursor.execute(queries.links_select_id, (id_, )) res = cursor.fetchone() # Do not allow creating more than one link per item if res: oldtarget = res['L_target'] do_update_link(filename, cursor, target, id_) core_api.give_connection(filename, qconn) core_api.insert_history( filename, group, id_, 'link_update', description, str(target) if target is not None else None, oldtarget if str(oldtarget) is not None else None) else: oldtarget = False # 'target' can be None, thus allowing the creation of a broken link do_insert_link(filename, cursor, id_, target) core_api.give_connection(filename, qconn) core_api.insert_history(filename, group, id_, 'link_insert', description, str(target) if target is not None else None, None) upsert_link_event.signal(filename=filename, id_=id_, target=target, oldtarget=oldtarget)