obj = session.query(Tag).get(tag.id) session.delete(obj) session.commit() except Exception, e: msg = _('Could not delete.\n\n%s') % utils.xml_safe(e) utils.message_details_dialog(msg, traceback.format_exc(), type=gtk.MESSAGE_ERROR) # reinitialize the tag menu _reset_tags_menu() return True edit_action = Action('acc_edit', _('_Edit'), callback=edit_callback, accelerator='<ctrl>e') remove_action = Action('tag_remove', _('_Delete'), callback=remove_callback, accelerator='<ctrl>Delete', multiselect=True) tag_context_menu = [edit_action, remove_action] class TagEditorPresenter(GenericEditorPresenter): widget_to_field_map = { 'tag_name_entry': 'tag', 'tag_desc_textbuffer': 'description'
return True def add_accession_callback(values): from bauble.plugins.garden.accession import Accession, AccessionEditor session = db.Session() species = session.merge(values[0]) if isinstance(species, VernacularName): species = species.species e = AccessionEditor(model=Accession(species=species)) session.close() return e.start() is not None edit_action = Action('species_edit', _('_Edit'), callback=edit_callback, accelerator='<ctrl>e') add_accession_action = Action('species_acc_add', _('_Add accession'), callback=add_accession_callback, accelerator='<ctrl>k') remove_action = Action('species_remove', _('_Delete'), callback=remove_callback, accelerator='<ctrl>Delete', multiselect=True) species_context_menu = [edit_action, remove_action] vernname_context_menu = [edit_action]
try: obj = session.query(Genus).get(genus.id) session.delete(obj) session.commit() except Exception, e: msg = _('Could not delete.\n\n%s') % utils.xml_safe(e) utils.message_details_dialog(msg, traceback.format_exc(), type=gtk.MESSAGE_ERROR) finally: session.close() return True edit_action = Action('genus_edit', _('_Edit'), callback=edit_callback, accelerator='<ctrl>e') add_species_action = Action('genus_sp_add', _('_Add species'), callback=add_species_callback, accelerator='<ctrl>k') remove_action = Action('genus_remove', _('_Delete'), callback=remove_callback, accelerator='<ctrl>Delete', multiselect=True) genus_context_menu = [edit_action, add_species_action, remove_action] def genus_markup_func(genus):
return try: session = db.Session() obj = session.query(Location).get(loc.id) session.delete(obj) session.commit() except Exception, e: msg = _('Could not delete.\n\n%s') % utils.xml_safe(e) utils.message_details_dialog(msg, traceback.format_exc(), type=gtk.MESSAGE_ERROR) return True edit_action = Action('loc_edit', _('_Edit'), callback=edit_callback, accelerator='<ctrl>e') add_plant_action = Action('loc_add_plant', _('_Add plants'), callback=add_plants_callback, accelerator='<ctrl>k') remove_action = Action('loc_remove', _('_Delete'), callback=remove_callback, accelerator='<ctrl>Delete', multiselect=True) loc_context_menu = [edit_action, add_plant_action, remove_action] def loc_markup_func(location):