From e7b77ccb831bd5938330ee9fe277e387258d1258 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 26 May 2004 03:26:18 +0000 Subject: [PATCH] * src/RelLib.py (Transaction.__len__): Redefine length. * src/ChooseParents.py, src/EditPerson.py, src/EditSource.py, src/EventEdit.py, src/FamilyView.py, src/gramps_main.py, src/ImageSelect.py, src/Marriage.py, src/MediaView.py, src/PedView.py, src/PeopleModel.py, src/PlaceView.py, src/SelectChild.py, src/SelectObject.py, src/Sources.py, src/SourceView.py, src/Utils.py, src/Witness.py, src/WriteXML.py: Switch from find_* to try_to_find_* methods. svn: r3193 --- gramps2/ChangeLog | 9 +++++++++ gramps2/src/ChooseParents.py | 16 ++++++++-------- gramps2/src/EditPerson.py | 30 +++++++++++++++--------------- gramps2/src/EditSource.py | 12 ++++++------ gramps2/src/EventEdit.py | 2 +- gramps2/src/FamilyView.py | 20 ++++++++++---------- gramps2/src/ImageSelect.py | 20 ++++++++++---------- gramps2/src/Marriage.py | 28 ++++++++++++++-------------- gramps2/src/MediaView.py | 10 +++++----- gramps2/src/PedView.py | 8 ++++---- gramps2/src/PeopleModel.py | 10 ++++++---- gramps2/src/PlaceView.py | 2 +- gramps2/src/SelectChild.py | 16 ++++++++-------- gramps2/src/SelectObject.py | 10 ++++++---- gramps2/src/SourceView.py | 2 +- gramps2/src/Sources.py | 12 ++++++------ gramps2/src/Utils.py | 8 ++++---- gramps2/src/Witness.py | 4 ++-- gramps2/src/WriteXML.py | 6 +++--- gramps2/src/gramps_main.py | 24 +++++++++++------------- 20 files changed, 130 insertions(+), 119 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 2ba981a2b..a230f10e7 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -26,6 +26,15 @@ * src/plugins/changetype.glade: HIGify dialog. * src/plugins/PatchNames.py: Correct transaction. + * src/RelLib.py (Transaction.__len__): Redefine length. + * src/ChooseParents.py, src/EditPerson.py, src/EditSource.py, + src/EventEdit.py, src/FamilyView.py, src/gramps_main.py, + src/ImageSelect.py, src/Marriage.py, src/MediaView.py, + src/PedView.py, src/PeopleModel.py, src/PlaceView.py, + src/SelectChild.py, src/SelectObject.py, src/Sources.py, + src/SourceView.py, src/Utils.py, src/Witness.py, + src/WriteXML.py: Switch from find_* to try_to_find_* methods. + 2004-05-24 Don Allingham * src/PeopleModel.py: temporary fix for add person update * src/PeopleView.py: temporary fix for add person update diff --git a/gramps2/src/ChooseParents.py b/gramps2/src/ChooseParents.py index e527ea726..9876d8980 100644 --- a/gramps2/src/ChooseParents.py +++ b/gramps2/src/ChooseParents.py @@ -80,7 +80,7 @@ class ChooseParents: self.parent = parent self.db = db self.child_windows = {} - self.person = self.db.find_person_from_id(person.get_id()) + self.person = self.db.try_to_find_person_from_id(person.get_id()) if family: self.family = self.db.find_family_from_id(family.get_id()) else: @@ -370,11 +370,11 @@ class ChooseParents: family.add_child_id(self.person.get_id()) if father_id: - self.father = self.db.find_person_from_id(father_id) + self.father = self.db.try_to_find_person_from_id(father_id) self.father.add_family_id(family.get_id()) self.db.commit_person(self.father,trans) if mother_id: - self.mother = self.db.find_person_from_id(mother_id) + self.mother = self.db.try_to_find_person_from_id(mother_id) self.mother.add_family_id(family.get_id()) self.db.commit_person(self.mother,trans) @@ -432,7 +432,7 @@ class ChooseParents: if len(family_id_list) >= 1: family = self.db.find_family_from_id(family_id_list[0]) mother_id = family.get_mother_id() - mother = self.db.find_person_from_id(mother_id) + mother = self.db.try_to_find_person_from_id(mother_id) sname = mother.get_primary_name().get_surname() tpath = self.mother_nsort.on_get_path(sname) self.mother_list.expand_row(tpath,0) @@ -456,7 +456,7 @@ class ChooseParents: if len(family_id_list) >= 1: family = self.db.find_family_from_id(family_id_list[0]) father_id = family.get_mother_id() - father = self.db.find_person_from_id(father_id) + father = self.db.try_to_find_person_from_id(father_id) sname = father.get_primary_name().get_surname() tpath = self.father_nsort.on_get_path(sname) self.father_list.expand_row(tpath,0) @@ -594,7 +594,7 @@ class ChooseParents: self.db.commit_person(self.father,trans) if self.mother: self.db.commit_person(self.mother,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Choose Parents")) class ModifyParents: def __init__(self,db,person,family_id,family_update,full_update,parent_window=None): @@ -613,8 +613,8 @@ class ModifyParents: self.family_update = family_update self.full_update = full_update - self.father = self.db.find_person_from_id(self.family.get_father_id()) - self.mother = self.db.find_person_from_id(self.family.get_mother_id()) + self.father = self.db.try_to_find_person_from_id(self.family.get_father_id()) + self.mother = self.db.try_to_find_person_from_id(self.family.get_mother_id()) self.glade = gtk.glade.XML(const.gladeFile,"modparents","gramps") self.top = self.glade.get_widget("modparents") diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 929606600..b33931d9b 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -475,7 +475,7 @@ class EditPerson: build_dropdown(place,self.place_list) if ord and ord.get_place_id(): - ord_place = self.db.find_place_from_id(ord.get_place_id(),None) + ord_place = self.db.try_to_find_place_from_id(ord.get_place_id()) place.set_text(ord_place.get_title()) return stat @@ -535,8 +535,8 @@ class EditPerson: continue f_id = fam.get_father_id() m_id = fam.get_mother_id() - f = self.db.find_person_from_id(f_id) - m = self.db.find_person_from_id(m_id) + f = self.db.try_to_find_person_from_id(f_id) + m = self.db.try_to_find_person_from_id(m_id) if f and m: name = _("%(father)s and %(mother)s") % { 'father' : GrampsCfg.nameof(f), @@ -626,7 +626,7 @@ class EditPerson: foo = pickle.loads(data[2]); for src in foo.get_source_references(): base_id = src.get_base_id() - newbase = self.db.find_source_from_id(base_id) + newbase = self.db.try_to_find_source_from_id(base_id) src.set_base_id(newbase) place = foo.get_place_id() if place: @@ -704,7 +704,7 @@ class EditPerson: foo = pickle.loads(data[2]); for src in foo.get_source_references(): base_id = src.get_base_id() - newbase = self.db.find_source_from_id(base_id) + newbase = self.db.try_to_find_source_from_id(base_id) src.set_base_id(newbase) self.alist.append(foo) self.lists_changed = 1 @@ -737,7 +737,7 @@ class EditPerson: foo = pickle.loads(data[2]); for src in foo.get_source_references(): base_id = src.get_base_id() - newbase = self.db.find_source_from_id(base_id) + newbase = self.db.try_to_find_source_from_id(base_id) src.set_base_id(newbase) self.plist.insert(row,foo) @@ -1229,7 +1229,7 @@ class EditPerson: if len(event.get_source_references()) > 0: psrc_ref = event.get_source_references()[0] psrc_id = psrc_ref.get_base_id() - psrc = self.db.find_source_from_id(psrc_id) + psrc = self.db.try_to_find_source_from_id(psrc_id) self.event_src_field.set_text(short(psrc.get_title())) self.event_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) else: @@ -1262,7 +1262,7 @@ class EditPerson: if len(addr.get_source_references()) > 0: psrc_ref = addr.get_source_references()[0] psrc_id = psrc_ref.get_base_id() - psrc = self.db.find_source_from_id(psrc_id) + psrc = self.db.try_to_find_source_from_id(psrc_id) self.addr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) self.addr_src_field.set_text(short(psrc.get_title())) else: @@ -1296,7 +1296,7 @@ class EditPerson: if len(name.get_source_references()) > 0: psrc_ref = name.get_source_references()[0] psrc_id = psrc_ref.get_base_id() - psrc = self.db.find_source_from_id(psrc_id) + psrc = self.db.try_to_find_source_from_id(psrc_id) self.name_src_field.set_text(short(psrc.get_title())) self.name_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) else: @@ -1343,7 +1343,7 @@ class EditPerson: if len(attr.get_source_references()) > 0: psrc_ref = attr.get_source_references()[0] psrc_id = psrc_ref.get_base_id() - psrc = self.db.find_source_from_id(psrc_id) + psrc = self.db.try_to_find_source_from_id(psrc_id) self.attr_src_field.set_text(short(psrc.get_title())) self.attr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) else: @@ -1659,7 +1659,7 @@ class EditPerson: if media_list: ph = media_list[0] object_id = ph.get_reference_id() - object = self.db.find_object_from_id(object_id,None) + object = self.db.try_to_find_object_from_id(object_id) if self.load_obj != object.get_path(): if object.get_mime_type()[0:5] == "image": self.load_photo(object.get_path()) @@ -1735,7 +1735,7 @@ class EditPerson: prev_date = "00000000" for i in range(len(list)): child_id = list[i] - child = self.db.find_person_from_id(child_id) + child = self.db.try_to_find_person_from_id(child_id) if child.get_birth_id(): event = self.db.find_event_from_id(child.get_birth_id()) bday = event.get_date_object() @@ -1768,7 +1768,7 @@ class EditPerson: index = list.index(person) target = index for i in range(index-1, -1, -1): - other = self.db.find_person_from_id(list[i]) + other = self.db.try_to_find_person_from_id(list[i]) event_id = other.get_birth_id() if event_id: event = self.db.find_event_from_id(event_id) @@ -1783,7 +1783,7 @@ class EditPerson: # Now try moving to a later position in the list if (target == index): for i in range(index, len(list)): - other = self.db.find_person_from_id(list[i]) + other = self.db.try_to_find_person_from_id(list[i]) event_id = other.get_birth_id() if event_id: event = self.db.find_event_from_id(event_id) @@ -1811,7 +1811,7 @@ def short(val,size=60): def place_title(db,event): pid = event.get_place_id() if pid: - return db.find_place_from_id(pid,None).get_title() + return db.try_to_find_place_from_id(pid).get_title() else: return u'' diff --git a/gramps2/src/EditSource.py b/gramps2/src/EditSource.py index 432b147ce..35f3e6f99 100644 --- a/gramps2/src/EditSource.py +++ b/gramps2/src/EditSource.py @@ -218,7 +218,7 @@ class EditSource: if sref.get_base_id() == self.source.get_id(): p_addr_list.append((name,v.get_street())) for object_id in self.db.get_object_keys(): - object = self.db.find_object_from_id(object_id,None) + object = self.db.try_to_find_object_from_id(object_id,None) name = object.get_description() for sref in object.get_source_references(): if sref.get_base_id() == self.source.get_id(): @@ -228,9 +228,9 @@ class EditSource: f_id = family.get_father_id() m_id = family.get_mother_id() if f_id: - f = self.db.find_person_from_id(f_id,None) + f = self.db.try_to_find_person_from_id(f_id,None) if m_id: - m = self.db.find_person_from_id(m_id,None) + m = self.db.try_to_find_person_from_id(m_id,None) if f_id and m_id: name = _("%(father)s and %(mother)s") % { "father" : GrampsCfg.nameof(f), @@ -404,13 +404,13 @@ class DelSrcQuery: self.db.commit_family(p,trans) for p_id in self.db.get_object_keys(): - p = self.db.find_object_from_id(p_id,trans) + p = self.db.try_to_find_object_from_id(p_id,trans) if self.delete_source(p): self.db.commit_media_object(p,trans) for key in self.db.get_place_id_keys(): - p = self.db.find_place_from_id(key) - if self.delete_source(self.db.find_place_from_id(key)): + p = self.db.try_to_find_place_from_id(key) + if self.delete_source(self.db.try_to_find_place_from_id(key)): self.db.commit_place(p,trans) self.db.remove_source_id(self.source.get_id(),trans) diff --git a/gramps2/src/EventEdit.py b/gramps2/src/EventEdit.py index ae9bd06b4..f8f1c77c7 100644 --- a/gramps2/src/EventEdit.py +++ b/gramps2/src/EventEdit.py @@ -172,7 +172,7 @@ class EventEditor: if place_id: place_name = u"" else: - place_name = self.db.find_place_from_id(place_id).get_title() + place_name = self.db.try_to_find_place_from_id(place_id).get_title() self.place_field.set_text(place_name) self.date_field.set_text(self.date.get_date()) diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index b35920117..9dd94427d 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -837,7 +837,7 @@ class FamilyView: person_id = family.get_father_id() else: person_id = family.get_mother_id() - person = self.parent.db.find_person_from_id(person_id,None) + person = self.parent.db.try_to_find_person_from_id(person_id) self.parent.change_active_person(person) n = person.get_primary_name().get_name() @@ -857,7 +857,7 @@ class FamilyView: if self.parent.active_person: id = self.parent.active_person.get_id() - self.person = self.parent.db.find_person_from_id(id,None) + self.person = self.parent.db.try_to_find_person_from_id(id) else: self.person = None self.clear() @@ -909,7 +909,7 @@ class FamilyView: flist[f] = iter if sp_id: - sp = self.parent.db.find_person_from_id(sp_id,None) + sp = self.parent.db.try_to_find_person_from_id(sp_id) event = self.find_marriage(fm) if event: mdate = " - %s" % event.get_date() @@ -955,8 +955,8 @@ class FamilyView: fam = self.parent.db.find_family_from_id(f) father_id = fam.get_father_id() mother_id = fam.get_mother_id() - f = self.parent.db.find_person_from_id(father_id,None) - m = self.parent.db.find_person_from_id(mother_id,None) + f = self.parent.db.try_to_find_person_from_id(father_id) + m = self.parent.db.try_to_find_person_from_id(mother_id) father = self.nameof(_("Father"),f,frel) mother = self.nameof(_("Mother"),m,mrel) @@ -1001,13 +1001,13 @@ class FamilyView: if self.family.get_father_id() == self.person.get_id(): sp_id = self.family.get_mother_id() if sp_id: - self.selected_spouse = self.parent.db.find_person_from_id(sp_id,None) + self.selected_spouse = self.parent.db.try_to_find_person_from_id(sp_id) else: self.selected_spouse = None else: sp_id = self.family.get_father_id() if sp_id: - self.selected_spouse = self.parent.db.find_person_from_id(sp_id,None) + self.selected_spouse = self.parent.db.try_to_find_person_from_id(sp_id) else: self.selected_spouse = None @@ -1024,7 +1024,7 @@ class FamilyView: for child_id in child_list: status = _("Unknown") - child = self.parent.db.find_person_from_id(child_id,None) + child = self.parent.db.try_to_find_person_from_id(child_id) for fam in child.get_parent_family_id_list(): if fam[0] == self.family.get_id(): if self.person == self.family.get_father_id(): @@ -1381,9 +1381,9 @@ class FamilyView: prev_date = "00000000" for i in range(len(list)): child_id = list[i] - child = self.parent.db.find_person_from_id(child_id,None) + child = self.parent.db.try_to_find_person_from_id(child_id) birth_id = child.get_birth_id() - birth = self.parent.db.find_event_from_id(birth_id) + birth = self.parent.db.try_to_find_event_from_id(birth_id) if not birth: continue bday = birth.get_date_object() diff --git a/gramps2/src/ImageSelect.py b/gramps2/src/ImageSelect.py index 140a9ad7b..026db3cf0 100644 --- a/gramps2/src/ImageSelect.py +++ b/gramps2/src/ImageSelect.py @@ -169,7 +169,7 @@ class ImageSelect: trans = self.db.start_transactions() for o_id in self.db.get_object_keys(): - o = self.db.find_object_from_id(o_id,trans) + o = self.db.try_to_find_object_from_id(o_id,trans) if o.get_path() == filename: already_imported = o break @@ -276,7 +276,7 @@ class Gallery(ImageSelect): def on_drag_begin(self,obj,context): if const.dnd_images: id = self.sel_obj.get_reference_id() - obj = self.db.find_object_from_id(id,None) + obj = self.db.try_to_find_object_from_id(id,None) mtype = obj.get_mime_type() name = Utils.thumb_path(self.db.get_save_path(),obj) pix = gtk.gdk.pixbuf_new_from_file(name) @@ -370,7 +370,7 @@ class Gallery(ImageSelect): def add_thumbnail(self, photo): """Scale the image and add it to the IconList.""" oid = photo.get_reference_id() - object = self.db.find_object_from_id(oid,None) + object = self.db.try_to_find_object_from_id(oid,None) if self.canvas_list.has_key(oid): (grp,item,text,x,y) = self.canvas_list[oid] if x != self.cx or y != self.cy: @@ -603,7 +603,7 @@ class Gallery(ImageSelect): menu = gtk.Menu() menu.set_title(_("Media Object")) - object = self.db.find_object_from_id(photo.get_reference_id(),None) + object = self.db.try_to_find_object_from_id(photo.get_reference_id(),None) mtype = object.get_mime_type() progname = GrampsMime.get_application(mtype) @@ -620,21 +620,21 @@ class Gallery(ImageSelect): def popup_view_photo(self, obj): """Open this picture in a picture viewer""" photo = obj.get_data('o') - Utils.view_photo(self.db.find_object_from_id(photo.get_reference_id(), + Utils.view_photo(self.db.try_to_find_object_from_id(photo.get_reference_id(), None)) def popup_edit_photo(self, obj): """Open this picture in a picture editor""" photo = obj.get_data('o') if os.fork() == 0: - obj = self.db.find_object_from_id(photo.get_reference_id(),None) + obj = self.db.try_to_find_object_from_id(photo.get_reference_id(),None) os.execvp(const.editor,[const.editor, obj.get_path()]) def popup_convert_to_private(self, obj): """Copy this picture into gramps private database instead of leaving it as an external data object.""" photo = obj.get_data('o') - object = self.db.find_object_from_id(photo.get_reference_id(),None) + object = self.db.try_to_find_object_from_id(photo.get_reference_id(),None) name = RelImage.import_media_object(object.get_path(),self.path, object.get_id()) object.set_path(name) @@ -665,7 +665,7 @@ class LocalMediaProperties: self.child_windows = {} self.photo = photo self.db = parent.db - self.object = self.db.find_object_from_id(photo.get_reference_id(), + self.object = self.db.try_to_find_object_from_id(photo.get_reference_id(), None) self.alist = photo.get_attribute_list()[:] self.lists_changed = 0 @@ -1119,7 +1119,7 @@ class DeleteMediaQuery: self.db.commit_family(p,trans) for key in self.db.get_source_keys(): - sid = self.db.find_source_from_id(key,trans) + sid = self.db.try_to_find_source_from_id(key,trans) nl = [] change = 0 for photo in p.get_media_list(): @@ -1132,7 +1132,7 @@ class DeleteMediaQuery: self.db.commit_source(p,trans) for key in self.db.get_place_id_keys(): - p = self.db.find_place_from_id(key) + p = self.db.try_to_find_place_from_id(key) nl = [] change = 0 for photo in p.get_media_list(): diff --git a/gramps2/src/Marriage.py b/gramps2/src/Marriage.py index e98b66d64..95cfe8757 100644 --- a/gramps2/src/Marriage.py +++ b/gramps2/src/Marriage.py @@ -132,12 +132,12 @@ class Marriage: mid = family.get_mother_id() if fid: - father = self.db.find_person_from_id(family.get_father_id()) + father = self.db.try_to_find_person_from_id(family.get_father_id()) else: father = None if mid: - mother = self.db.find_person_from_id(family.get_mother_id()) + mother = self.db.try_to_find_person_from_id(family.get_mother_id()) else: mother = None @@ -393,11 +393,11 @@ class Marriage: foo = pickle.loads(data[2]); for src in foo.get_source_references(): base_id = src.get_base_id() - newbase = self.db.find_source_from_id(base_id) + newbase = self.db.try_to_find_source_from_id(base_id) src.set_base_id(newbase) place = foo.get_place_id() if place: - foo.set_place_id(self.db.find_place_from_id(place.get_id())) + foo.set_place_id(self.db.try_to_find_place_from_id(place.get_id())) self.elist.insert(row,foo) self.lists_changed = 1 @@ -425,7 +425,7 @@ class Marriage: foo = pickle.loads(data[2]); for src in foo.get_source_references(): base_id = src.get_base_id() - newbase = self.db.find_source_from_id(base_id) + newbase = self.db.try_to_find_source_from_id(base_id) src.set_base_id(newbase) self.alist.insert(row,foo) @@ -471,7 +471,7 @@ class Marriage: place_id = event.get_place_id() if place_id: - place_name = self.db.find_place_from_id(place_id).get_title() + place_name = self.db.try_to_find_place_from_id(place_id).get_title() else: place_name = "" iter = self.etree.add([const.display_fevent(event.get_name()), @@ -678,7 +678,7 @@ class Marriage: self.date_field.set_text(event.get_date()) place_id = event.get_place_id() if place_id: - place_name = self.db.find_place_from_id(place_id).get_title() + place_name = self.db.try_to_find_place_from_id(place_id).get_title() else: place_name = u"" self.place_field.set_text(place_name) @@ -687,7 +687,7 @@ class Marriage: if len(event.get_source_references()) > 0: psrc_ref = event.get_source_references()[0] psrc_id = psrc_ref.get_base_id() - psrc = self.db.find_source_from_id(psrc_id) + psrc = self.db.try_to_find_source_from_id(psrc_id) self.event_src_field.set_text(psrc.get_title()) self.event_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) else: @@ -706,7 +706,7 @@ class Marriage: if len(attr.get_source_references()) > 0: psrc_ref = attr.get_source_references()[0] psrc_id = psrc_ref.get_base_id() - psrc = self.db.find_source_from_id(psrc_id) + psrc = self.db.try_to_find_source_from_id(psrc_id) self.attr_src_field.set_text(psrc.get_title()) self.attr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) else: @@ -723,8 +723,8 @@ class Marriage: father_id = self.family.get_father_id() mother_id = self.family.get_mother_id() - father = self.db.find_person_from_id(father_id) - mother = self.db.find_person_from_id(mother_id) + father = self.db.try_to_find_person_from_id(father_id) + mother = self.db.try_to_find_person_from_id(mother_id) if father and mother: name = _("%s and %s") % (father.get_primary_name().get_name(), mother.get_primary_name().get_name()) @@ -744,8 +744,8 @@ class Marriage: import AttrEdit father_id = self.family.get_father_id() mother_id = self.family.get_mother_id() - father = self.db.find_person_from_id(father_id) - mother = self.db.find_person_from_id(mother_id) + father = self.db.try_to_find_person_from_id(father_id) + mother = self.db.try_to_find_person_from_id(mother_id) if father and mother: name = _("%s and %s") % (father.get_primary_name().get_name(), mother.get_primary_name().get_name()) @@ -788,7 +788,7 @@ class Marriage: text = string.strip(unicode(field.get_text())) if text: if self.pmap.has_key(text): - return self.db.find_place_from_id(self.pmap[text],trans) + return self.db.try_to_find_place_from_id(self.pmap[text],trans) elif makenew: place = RelLib.Place() place.set_title(text) diff --git a/gramps2/src/MediaView.py b/gramps2/src/MediaView.py index 9f746c1c9..6b31adbb3 100644 --- a/gramps2/src/MediaView.py +++ b/gramps2/src/MediaView.py @@ -177,7 +177,7 @@ class MediaView: id = store.get_value(iter,1) - mobj = self.db.find_object_from_id(id,None) + mobj = self.db.try_to_find_object_from_id(id,None) type = mobj.get_mime_type() type_name = Utils.get_mime_description(type) path = mobj.get_path() @@ -225,7 +225,7 @@ class MediaView: store,iter = self.selection.get_selected() if iter: id = store.get_value(iter,1) - object = self.db.find_object_from_id(id,None) + object = self.db.try_to_find_object_from_id(id,None) self.obj = object mime_type = object.get_mime_type() @@ -290,7 +290,7 @@ class MediaView: list_store, iter = self.selection.get_selected() if iter: id = list_store.get_value(iter,1) - object = self.db.find_object_from_id(id,None) + object = self.db.try_to_find_object_from_id(id,None) ImageSelect.GlobalMediaProperties(self.db,object,self.load_media) def on_delete_clicked(self,obj): @@ -299,7 +299,7 @@ class MediaView: return id = store.get_value(iter,1) - mobj = self.db.find_object_from_id(id,None) + mobj = self.db.try_to_find_object_from_id(id,None) if self.is_object_used(mobj): ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree) QuestionDialog(_('Delete Media Object?'), @@ -343,7 +343,7 @@ class MediaView: if not iter: return if (const.dnd_images): - object = self.db.find_object_from_id(store.get_value(iter,1),None) + object = self.db.try_to_find_object_from_id(store.get_value(iter,1),None) mtype = object.get_mime_type() name = Utils.thumb_path(self.db.get_save_path(),object) pix = gtk.gdk.pixbuf_new_from_file(name) diff --git a/gramps2/src/PedView.py b/gramps2/src/PedView.py index 6b09fd224..dd0aab6e7 100644 --- a/gramps2/src/PedView.py +++ b/gramps2/src/PedView.py @@ -366,13 +366,13 @@ class PedigreeView: childlist = find_children(self.active_person) if len(childlist) == 1: - child = self.parent.db.find_person_from_id(childlist[0],None) + child = self.parent.db.try_to_find_person_from_id(childlist[0],None) if child: self.load_canvas(child) elif len(childlist) > 1: myMenu = gtk.Menu() for child_id in childlist: - child = self.parent.db.find_person_from_id(child_id,None) + child = self.parent.db.try_to_find_person_from_id(child_id,None) cname = GrampsCfg.nameof(child) menuitem = gtk.MenuItem(None) if find_children(child): @@ -485,11 +485,11 @@ class PedigreeView: if family != None: father_id = family.get_father_id() if father_id != None: - father = self.parent.db.find_person_from_id(father_id,None) + father = self.parent.db.try_to_find_person_from_id(father_id,None) self.find_tree(father,(2*index)+1,depth+1,list,frel) mother_id = family.get_mother_id() if mother_id != None: - mother = self.parent.db.find_person_from_id(mother_id,None) + mother = self.parent.db.try_to_find_person_from_id(mother_id,None) self.find_tree(mother,(2*index)+2,depth+1,list,mrel) def on_canvas1_event(self,obj,event): diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 07c2452a1..de24d727c 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2003 Donald N. Allingham +# Copyright (C) 2000-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + #------------------------------------------------------------------------- # # Standard python modules @@ -127,7 +129,7 @@ class PeopleModel(gtk.GenericTreeModel): for person_id in self.db.get_person_keys(): - person = self.db.find_person_from_id(person_id,None) + person = self.db.try_to_find_person_from_id(person_id) surname = unicode(person.get_primary_name().get_surname()) if self.sname_sub.has_key(surname): @@ -344,7 +346,7 @@ class PeopleModel(gtk.GenericTreeModel): if event: place_id = event.get_place_id() if place_id: - return self.db.find_place_from_id(place_id).get_title() + return self.db.try_to_find_place_from_id(place_id).get_title() return u"" def column_death_place(self,data): @@ -353,7 +355,7 @@ class PeopleModel(gtk.GenericTreeModel): if event: place_id = event.get_place_id() if place_id: - return self.db.find_place_from_id(place_id).get_title() + return self.db.try_to_find_place_from_id(place_id).get_title() return u"" _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] diff --git a/gramps2/src/PlaceView.py b/gramps2/src/PlaceView.py index 59dd73d96..e3614c560 100644 --- a/gramps2/src/PlaceView.py +++ b/gramps2/src/PlaceView.py @@ -198,7 +198,7 @@ class PlaceView: for place in mlist: used = 0 for key in self.db.get_person_keys(): - p = self.db.find_person_from_id(key) + p = self.db.try_to_find_person_from_id(key) event_list = [] for e in [p.get_birth_id(),p.get_death_id()] + p.get_event_list(): event = self.db.find_event_from_id(e) diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py index ae16a904a..beb130632 100644 --- a/gramps2/src/SelectChild.py +++ b/gramps2/src/SelectChild.py @@ -88,8 +88,8 @@ class SelectChild: self.add_child = self.xml.get_widget("childlist") if (self.family): - father = self.db.find_person_from_id(self.family.get_father_id()) - mother = self.db.find_person_from_id(self.family.get_mother_id()) + father = self.db.try_to_find_person_from_id(self.family.get_father_id()) + mother = self.db.try_to_find_person_from_id(self.family.get_mother_id()) if father != None: fname = father.get_primary_name().get_name() @@ -300,13 +300,13 @@ class SelectChild: self.family.add_child_id(select_child.get_id()) mrel = const.child_relations.find_value(self.mrel.get_text()) - mother = self.db.find_person_from_id(self.family.get_mother_id()) + mother = self.db.try_to_find_person_from_id(self.family.get_mother_id()) if mother and mother.get_gender() != RelLib.Person.female: if mrel == "Birth": mrel = "Unknown" frel = const.child_relations.find_value(self.frel.get_text()) - father = self.db.find_person_from_id(self.family.get_father_id()) + father = self.db.try_to_find_person_from_id(self.family.get_father_id()) if father and father.get_gender() !=RelLib. Person.male: if frel == "Birth": frel = "Unknown" @@ -393,8 +393,8 @@ class EditRel: Utils.set_titles(self.top,self.xml.get_widget('title'), _('Relationships of %s') % name) - father = self.db.find_person_from_id(self.family.get_father_id()) - mother = self.db.find_person_from_id(self.family.get_mother_id()) + father = self.db.try_to_find_person_from_id(self.family.get_father_id()) + mother = self.db.try_to_find_person_from_id(self.family.get_mother_id()) if father: fname = father.get_primary_name().get_name() @@ -436,13 +436,13 @@ class EditRel: def on_ok_clicked(self,obj): mrel = const.child_relations.find_value(self.mentry.get_text()) - mother = self.db.find_person_from_id(self.family.get_mother_id()) + mother = self.db.try_to_find_person_from_id(self.family.get_mother_id()) if mother and mother.get_gender() != RelLib.Person.female: if mrel == "Birth": mrel = "Unknown" frel = const.child_relations.find_value(self.fentry.get_text()) - father = self.db.find_person_from_id(self.family.get_father_id()) + father = self.db.try_to_find_person_from_id(self.family.get_father_id()) if father and father.get_gender() !=RelLib. Person.male: if frel == "Birth": frel = "Unknown" diff --git a/gramps2/src/SelectObject.py b/gramps2/src/SelectObject.py index 168f3aabe..07ce20bde 100644 --- a/gramps2/src/SelectObject.py +++ b/gramps2/src/SelectObject.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003 Donald N. Allingham +# Copyright (C) 2003-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + # # Written by Alex Roitman, # largely based on the MediaView and SelectPerson by Don Allingham @@ -98,7 +100,7 @@ class SelectObject: self.object_model.new_model() for key in self.db.get_object_keys(): - object = self.db.find_object_from_id(key,None) + object = self.db.try_to_find_object_from_id(key,None) title = object.get_description() the_id = object.get_id() the_type = Utils.get_mime_description(object.get_mime_type()) @@ -115,7 +117,7 @@ class SelectObject: return data = self.object_model.get_data(iter,range(self.ncols)) the_id = data[4] - object = self.db.find_object_from_id(the_id,None) + object = self.db.try_to_find_object_from_id(the_id,None) the_type = Utils.get_mime_description(object.get_mime_type()) path = object.get_path() @@ -148,7 +150,7 @@ class SelectObject: if iter: data = self.object_model.get_data(iter,range(self.ncols)) the_id = data[4] - return_value = self.db.find_object_from_id(the_id,None) + return_value = self.db.try_to_find_object_from_id(the_id,None) else: return_value = None self.top.destroy() diff --git a/gramps2/src/SourceView.py b/gramps2/src/SourceView.py index f0f18baf8..bf9a885fe 100644 --- a/gramps2/src/SourceView.py +++ b/gramps2/src/SourceView.py @@ -229,7 +229,7 @@ class SourceView: if sref.get_base_id() == source.get_id(): return 1 for p_id in self.db.get_object_keys(): - p = self.db.find_object_from_id(p_id) + p = self.db.try_to_find_object_from_id(p_id) for sref in p.get_source_references(): if sref.get_base_id() == source.get_id(): return 1 diff --git a/gramps2/src/Sources.py b/gramps2/src/Sources.py index 9386cba10..c20893ee1 100644 --- a/gramps2/src/Sources.py +++ b/gramps2/src/Sources.py @@ -162,7 +162,7 @@ class SourceSelector: self.model.clear() for s in self.list: base_id = s.get_base_id() - base = self.db.find_source_from_id(base_id) + base = self.db.try_to_find_source_from_id(base_id) iter = self.model.append() self.model.set(iter,0,base_id,1,base.get_title()) @@ -244,7 +244,7 @@ class SourceTab: for s in self.list: base_id = s.get_base_id() iter = self.model.append() - base = self.db.find_source_from_id(base_id) + base = self.db.try_to_find_source_from_id(base_id) self.model.set(iter,0,base_id,1,base.get_title()) if self.list: Utils.bold_label(self.parent.sources_label) @@ -334,7 +334,7 @@ class SourceEditor: self.pub_field = self.get_widget("spubinfo") if self.source_ref: - self.active_source = self.db.find_source_from_id(self.source_ref.get_base_id()) + self.active_source = self.db.try_to_find_source_from_id(self.source_ref.get_base_id()) else: self.active_source = None @@ -415,7 +415,7 @@ class SourceEditor: scom = self.get_widget("scomment") scom.get_buffer().set_text(self.source_ref.get_comments()) - src = self.db.find_source_from_id(self.source_ref.get_base_id()) + src = self.db.try_to_find_source_from_id(self.source_ref.get_base_id()) self.active_source = src if src: self.author_field.set_text(src.get_author()) @@ -431,7 +431,7 @@ class SourceEditor: self.list = [] self.active_source = sel for src_id in keys: - src = self.db.find_source_from_id(src_id) + src = self.db.try_to_find_source_from_id(src_id) l = gtk.Label("%s [%s]" % (src.get_title(),src.get_id())) l.show() l.set_alignment(0,0.5) @@ -453,7 +453,7 @@ class SourceEditor: def on_sourceok_clicked(self,obj): - if self.active_source != self.db.find_source_from_id(self.source_ref.get_base_id()): + if self.active_source != self.db.try_to_find_source_from_id(self.source_ref.get_base_id()): self.source_ref.set_base_id(self.active_source.get_id()) date = unicode(self.get_widget("sdate").get_text()) diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index fc816df19..f8bec0199 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -123,8 +123,8 @@ def family_name(family,db): """Builds a name for the family from the parents names""" father_id = family.get_father_id() mother_id = family.get_mother_id() - father = db.find_person_from_id(father_id,None) - mother = db.find_person_from_id(mother_id,None) + father = db.try_to_find_person_from_id(father_id,None) + mother = db.try_to_find_person_from_id(mother_id,None) if father and mother: fname = father.get_primary_name().get_name() mname = mother.get_primary_name().get_name() @@ -139,8 +139,8 @@ def family_upper_name(family,db): """Builds a name for the family from the parents names""" father_id = family.get_father_id() mother_id = family.get_mother_id() - father = db.find_person_from_id(father_id,None) - mother = db.find_person_from_id(mother_id,None) + father = db.try_to_find_person_from_id(father_id,None) + mother = db.try_to_find_person_from_id(mother_id,None) if father and mother: fname = father.get_primary_name().get_upper_name() mname = mother.get_primary_name().get_upper_name() diff --git a/gramps2/src/Witness.py b/gramps2/src/Witness.py index f9ab525af..9416b6d27 100644 --- a/gramps2/src/Witness.py +++ b/gramps2/src/Witness.py @@ -70,7 +70,7 @@ class WitnessTab: if s.get_type() == RelLib.Event.ID: id = s.get_value() if self.db.has_person_id(id): - n = self.db.find_person_from_id(id).get_primary_name().get_name() + n = self.db.try_to_find_person_from_id(id).get_primary_name().get_name() else: n = _('Unknown') self.model.add([n,s.get_value()],s) @@ -149,7 +149,7 @@ class WitnessEditor: if self.ref.get_type(): self.in_db.set_active(1) self.idval = self.ref.get_value() - person = self.db.find_person_from_id(self.idval) + person = self.db.try_to_find_person_from_id(self.idval) self.name.set_text(person.get_primary_name().get_regular_name()) else: self.name.set_text(self.ref.get_value()) diff --git a/gramps2/src/WriteXML.py b/gramps2/src/WriteXML.py index 0b0fbabb0..56386776a 100644 --- a/gramps2/src/WriteXML.py +++ b/gramps2/src/WriteXML.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2003 Donald N. Allingham +# Copyright (C) 2000-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -379,7 +379,7 @@ class XmlWriter: self.g.write(" \n") objList.sort () for key in self.db.get_object_keys(): - object = self.db.find_object_from_id(key) + object = self.db.try_to_find_object_from_id(key) self.write_object(object) self.g.write(" \n") @@ -493,7 +493,7 @@ class XmlWriter: self.g.write('%s\n' % sp) def dump_source_ref(self,source_ref,index=1): - source = self.db.find_source_from_id(source_ref.get_base_id()) + source = self.db.try_to_find_source_from_id(source_ref.get_base_id()) if source: p = source_ref.get_page() c = source_ref.get_comments() diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 334648156..a363a45bb 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -356,7 +356,7 @@ class Gramps: def undo(self,*args): self.db.undo() if self.active_person: - p = self.db.try_to_find_person_from_id(self.active_person.get_id(),None) + p = self.db.try_to_find_person_from_id(self.active_person.get_id()) self.change_active_person(p) self.place_view.change_db(self.db) self.people_view.change_db(self.db) @@ -503,7 +503,7 @@ class Gramps: hotkey = "_%s" % chr(ord('a')+num-11) elif num >= 21: break - person = self.db.find_person_from_id(pid) + person = self.db.try_to_find_person_from_id(pid) item = gtk.MenuItem("%s. %s [%s]" % (hotkey,person.get_primary_name().get_name(),pid)) item.connect("activate",self.back_clicked,num) @@ -1091,7 +1091,7 @@ class Gramps: #------------------------------------------------------------------------- def remove_clicked(): # File is lost => remove all references and the object itself - mobj = self.db.find_object_from_id(ObjectId,trans) + mobj = self.db.try_to_find_object_from_id(ObjectId) for p in self.db.get_family_id_map().values(): nl = p.get_media_list() for o in nl: @@ -1147,13 +1147,13 @@ class Gramps: name = choose.get_filename() if os.path.isfile(name): RelImage.import_media_object(name,filename,base) - object = self.db.find_object_from_id(ObjectId,trans) + object = self.db.try_to_find_object_from_id(ObjectId) object.set_path(name) choose.destroy() #------------------------------------------------------------------------- for ObjectId in self.db.get_object_keys(): - object = self.db.find_object_from_id(ObjectId,trans) + object = self.db.try_to_find_object_from_id(ObjectId) if 0: oldfile = object.get_path() (base,ext) = os.path.splitext(os.path.basename(oldfile)) @@ -1288,7 +1288,7 @@ class Gramps: if self.active_person.get_id() == family.get_father_id(): if family.get_mother_id() == None: for child_id in family.get_child_id_list(): - child = self.db.find_person_from_id(child_id,trans) + child = self.db.try_to_find_person_from_id(child_id) child.remove_parent_family_id(family.get_id()) self.db.commit_person(child,trans) self.db.delete_family(family.get_id(),trans) @@ -1297,7 +1297,7 @@ class Gramps: else: if family.get_father_id() == None: for child_id in family.get_child_id_list(): - child = self.db.find_person_from_id(child_id,trans) + child = self.db.try_to_find_person_from_id(child_id) child.remove_parent_family_id(family) self.db.commit_person(child,trans) self.db.delete_family(family,trans) @@ -1317,7 +1317,7 @@ class Gramps: self.db.remove_person_id(id, trans) if self.hindex >= 0: - self.active_person = self.db.find_person_from_id(self.history[self.hindex],trans) + self.active_person = self.db.try_to_find_person_from_id(self.history[self.hindex]) else: self.change_active_person(None) self.db.add_transaction(trans,_("Delete Person (%s)") % n) @@ -1342,8 +1342,7 @@ class Gramps: self.modify_statusbar() elif self.active_person == None or \ person.get_id() != self.active_person.get_id(): - self.active_person = self.db.find_person_from_id(person.get_id(), - None) + self.active_person = self.db.try_to_find_person_from_id(person.get_id()) self.modify_statusbar() self.set_buttons(1) if person: @@ -1369,8 +1368,7 @@ class Gramps: self.backbtn.set_sensitive(0) self.back.set_sensitive(0) else: - self.active_person = self.db.find_person_from_id(person.get_id(), - None) + self.active_person = self.db.try_to_find_person_from_id(person.get_id()) self.set_buttons(1) def modify_statusbar(self): @@ -1674,7 +1672,7 @@ class Gramps: def bookmark_callback(self,obj,person_id): old_person = self.active_person - person = self.db.find_person_from_id(person_id,None) + person = self.db.try_to_find_person_from_id(person_id) try: self.change_active_person(person) self.update_display(0)