* 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
This commit is contained in:
Alex Roitman 2004-05-26 03:26:18 +00:00
parent 0739dd2b6b
commit e7b77ccb83
20 changed files with 130 additions and 119 deletions

View File

@ -26,6 +26,15 @@
* src/plugins/changetype.glade: HIGify dialog. * src/plugins/changetype.glade: HIGify dialog.
* src/plugins/PatchNames.py: Correct transaction. * 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 <dallingham@users.sourceforge.net> 2004-05-24 Don Allingham <dallingham@users.sourceforge.net>
* src/PeopleModel.py: temporary fix for add person update * src/PeopleModel.py: temporary fix for add person update
* src/PeopleView.py: temporary fix for add person update * src/PeopleView.py: temporary fix for add person update

View File

@ -80,7 +80,7 @@ class ChooseParents:
self.parent = parent self.parent = parent
self.db = db self.db = db
self.child_windows = {} 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: if family:
self.family = self.db.find_family_from_id(family.get_id()) self.family = self.db.find_family_from_id(family.get_id())
else: else:
@ -370,11 +370,11 @@ class ChooseParents:
family.add_child_id(self.person.get_id()) family.add_child_id(self.person.get_id())
if father_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.father.add_family_id(family.get_id())
self.db.commit_person(self.father,trans) self.db.commit_person(self.father,trans)
if mother_id: 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.mother.add_family_id(family.get_id())
self.db.commit_person(self.mother,trans) self.db.commit_person(self.mother,trans)
@ -432,7 +432,7 @@ class ChooseParents:
if len(family_id_list) >= 1: if len(family_id_list) >= 1:
family = self.db.find_family_from_id(family_id_list[0]) family = self.db.find_family_from_id(family_id_list[0])
mother_id = family.get_mother_id() 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() sname = mother.get_primary_name().get_surname()
tpath = self.mother_nsort.on_get_path(sname) tpath = self.mother_nsort.on_get_path(sname)
self.mother_list.expand_row(tpath,0) self.mother_list.expand_row(tpath,0)
@ -456,7 +456,7 @@ class ChooseParents:
if len(family_id_list) >= 1: if len(family_id_list) >= 1:
family = self.db.find_family_from_id(family_id_list[0]) family = self.db.find_family_from_id(family_id_list[0])
father_id = family.get_mother_id() 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() sname = father.get_primary_name().get_surname()
tpath = self.father_nsort.on_get_path(sname) tpath = self.father_nsort.on_get_path(sname)
self.father_list.expand_row(tpath,0) self.father_list.expand_row(tpath,0)
@ -594,7 +594,7 @@ class ChooseParents:
self.db.commit_person(self.father,trans) self.db.commit_person(self.father,trans)
if self.mother: if self.mother:
self.db.commit_person(self.mother,trans) self.db.commit_person(self.mother,trans)
self.db.add_transaction(trans) self.db.add_transaction(trans,_("Choose Parents"))
class ModifyParents: class ModifyParents:
def __init__(self,db,person,family_id,family_update,full_update,parent_window=None): 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.family_update = family_update
self.full_update = full_update self.full_update = full_update
self.father = self.db.find_person_from_id(self.family.get_father_id()) self.father = self.db.try_to_find_person_from_id(self.family.get_father_id())
self.mother = self.db.find_person_from_id(self.family.get_mother_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.glade = gtk.glade.XML(const.gladeFile,"modparents","gramps")
self.top = self.glade.get_widget("modparents") self.top = self.glade.get_widget("modparents")

View File

@ -475,7 +475,7 @@ class EditPerson:
build_dropdown(place,self.place_list) build_dropdown(place,self.place_list)
if ord and ord.get_place_id(): 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()) place.set_text(ord_place.get_title())
return stat return stat
@ -535,8 +535,8 @@ class EditPerson:
continue continue
f_id = fam.get_father_id() f_id = fam.get_father_id()
m_id = fam.get_mother_id() m_id = fam.get_mother_id()
f = self.db.find_person_from_id(f_id) f = self.db.try_to_find_person_from_id(f_id)
m = self.db.find_person_from_id(m_id) m = self.db.try_to_find_person_from_id(m_id)
if f and m: if f and m:
name = _("%(father)s and %(mother)s") % { name = _("%(father)s and %(mother)s") % {
'father' : GrampsCfg.nameof(f), 'father' : GrampsCfg.nameof(f),
@ -626,7 +626,7 @@ class EditPerson:
foo = pickle.loads(data[2]); foo = pickle.loads(data[2]);
for src in foo.get_source_references(): for src in foo.get_source_references():
base_id = src.get_base_id() 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) src.set_base_id(newbase)
place = foo.get_place_id() place = foo.get_place_id()
if place: if place:
@ -704,7 +704,7 @@ class EditPerson:
foo = pickle.loads(data[2]); foo = pickle.loads(data[2]);
for src in foo.get_source_references(): for src in foo.get_source_references():
base_id = src.get_base_id() 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) src.set_base_id(newbase)
self.alist.append(foo) self.alist.append(foo)
self.lists_changed = 1 self.lists_changed = 1
@ -737,7 +737,7 @@ class EditPerson:
foo = pickle.loads(data[2]); foo = pickle.loads(data[2]);
for src in foo.get_source_references(): for src in foo.get_source_references():
base_id = src.get_base_id() 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) src.set_base_id(newbase)
self.plist.insert(row,foo) self.plist.insert(row,foo)
@ -1229,7 +1229,7 @@ class EditPerson:
if len(event.get_source_references()) > 0: if len(event.get_source_references()) > 0:
psrc_ref = event.get_source_references()[0] psrc_ref = event.get_source_references()[0]
psrc_id = psrc_ref.get_base_id() 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_src_field.set_text(short(psrc.get_title()))
self.event_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) self.event_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()])
else: else:
@ -1262,7 +1262,7 @@ class EditPerson:
if len(addr.get_source_references()) > 0: if len(addr.get_source_references()) > 0:
psrc_ref = addr.get_source_references()[0] psrc_ref = addr.get_source_references()[0]
psrc_id = psrc_ref.get_base_id() 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_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()])
self.addr_src_field.set_text(short(psrc.get_title())) self.addr_src_field.set_text(short(psrc.get_title()))
else: else:
@ -1296,7 +1296,7 @@ class EditPerson:
if len(name.get_source_references()) > 0: if len(name.get_source_references()) > 0:
psrc_ref = name.get_source_references()[0] psrc_ref = name.get_source_references()[0]
psrc_id = psrc_ref.get_base_id() 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_src_field.set_text(short(psrc.get_title()))
self.name_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) self.name_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()])
else: else:
@ -1343,7 +1343,7 @@ class EditPerson:
if len(attr.get_source_references()) > 0: if len(attr.get_source_references()) > 0:
psrc_ref = attr.get_source_references()[0] psrc_ref = attr.get_source_references()[0]
psrc_id = psrc_ref.get_base_id() 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_src_field.set_text(short(psrc.get_title()))
self.attr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) self.attr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()])
else: else:
@ -1659,7 +1659,7 @@ class EditPerson:
if media_list: if media_list:
ph = media_list[0] ph = media_list[0]
object_id = ph.get_reference_id() 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 self.load_obj != object.get_path():
if object.get_mime_type()[0:5] == "image": if object.get_mime_type()[0:5] == "image":
self.load_photo(object.get_path()) self.load_photo(object.get_path())
@ -1735,7 +1735,7 @@ class EditPerson:
prev_date = "00000000" prev_date = "00000000"
for i in range(len(list)): for i in range(len(list)):
child_id = list[i] 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(): if child.get_birth_id():
event = self.db.find_event_from_id(child.get_birth_id()) event = self.db.find_event_from_id(child.get_birth_id())
bday = event.get_date_object() bday = event.get_date_object()
@ -1768,7 +1768,7 @@ class EditPerson:
index = list.index(person) index = list.index(person)
target = index target = index
for i in range(index-1, -1, -1): 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() event_id = other.get_birth_id()
if event_id: if event_id:
event = self.db.find_event_from_id(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 # Now try moving to a later position in the list
if (target == index): if (target == index):
for i in range(index, len(list)): 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() event_id = other.get_birth_id()
if event_id: if event_id:
event = self.db.find_event_from_id(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): def place_title(db,event):
pid = event.get_place_id() pid = event.get_place_id()
if pid: if pid:
return db.find_place_from_id(pid,None).get_title() return db.try_to_find_place_from_id(pid).get_title()
else: else:
return u'' return u''

View File

@ -218,7 +218,7 @@ class EditSource:
if sref.get_base_id() == self.source.get_id(): if sref.get_base_id() == self.source.get_id():
p_addr_list.append((name,v.get_street())) p_addr_list.append((name,v.get_street()))
for object_id in self.db.get_object_keys(): 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() name = object.get_description()
for sref in object.get_source_references(): for sref in object.get_source_references():
if sref.get_base_id() == self.source.get_id(): if sref.get_base_id() == self.source.get_id():
@ -228,9 +228,9 @@ class EditSource:
f_id = family.get_father_id() f_id = family.get_father_id()
m_id = family.get_mother_id() m_id = family.get_mother_id()
if f_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: 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: if f_id and m_id:
name = _("%(father)s and %(mother)s") % { name = _("%(father)s and %(mother)s") % {
"father" : GrampsCfg.nameof(f), "father" : GrampsCfg.nameof(f),
@ -404,13 +404,13 @@ class DelSrcQuery:
self.db.commit_family(p,trans) self.db.commit_family(p,trans)
for p_id in self.db.get_object_keys(): 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): if self.delete_source(p):
self.db.commit_media_object(p,trans) self.db.commit_media_object(p,trans)
for key in self.db.get_place_id_keys(): 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)
if self.delete_source(self.db.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.commit_place(p,trans)
self.db.remove_source_id(self.source.get_id(),trans) self.db.remove_source_id(self.source.get_id(),trans)

View File

@ -172,7 +172,7 @@ class EventEditor:
if place_id: if place_id:
place_name = u"" place_name = u""
else: 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.place_field.set_text(place_name)
self.date_field.set_text(self.date.get_date()) self.date_field.set_text(self.date.get_date())

View File

@ -837,7 +837,7 @@ class FamilyView:
person_id = family.get_father_id() person_id = family.get_father_id()
else: else:
person_id = family.get_mother_id() 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) self.parent.change_active_person(person)
n = person.get_primary_name().get_name() n = person.get_primary_name().get_name()
@ -857,7 +857,7 @@ class FamilyView:
if self.parent.active_person: if self.parent.active_person:
id = self.parent.active_person.get_id() 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: else:
self.person = None self.person = None
self.clear() self.clear()
@ -909,7 +909,7 @@ class FamilyView:
flist[f] = iter flist[f] = iter
if sp_id: 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) event = self.find_marriage(fm)
if event: if event:
mdate = " - %s" % event.get_date() mdate = " - %s" % event.get_date()
@ -955,8 +955,8 @@ class FamilyView:
fam = self.parent.db.find_family_from_id(f) fam = self.parent.db.find_family_from_id(f)
father_id = fam.get_father_id() father_id = fam.get_father_id()
mother_id = fam.get_mother_id() mother_id = fam.get_mother_id()
f = self.parent.db.find_person_from_id(father_id,None) f = self.parent.db.try_to_find_person_from_id(father_id)
m = self.parent.db.find_person_from_id(mother_id,None) m = self.parent.db.try_to_find_person_from_id(mother_id)
father = self.nameof(_("Father"),f,frel) father = self.nameof(_("Father"),f,frel)
mother = self.nameof(_("Mother"),m,mrel) mother = self.nameof(_("Mother"),m,mrel)
@ -1001,13 +1001,13 @@ class FamilyView:
if self.family.get_father_id() == self.person.get_id(): if self.family.get_father_id() == self.person.get_id():
sp_id = self.family.get_mother_id() sp_id = self.family.get_mother_id()
if sp_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: else:
self.selected_spouse = None self.selected_spouse = None
else: else:
sp_id = self.family.get_father_id() sp_id = self.family.get_father_id()
if sp_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: else:
self.selected_spouse = None self.selected_spouse = None
@ -1024,7 +1024,7 @@ class FamilyView:
for child_id in child_list: for child_id in child_list:
status = _("Unknown") 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(): for fam in child.get_parent_family_id_list():
if fam[0] == self.family.get_id(): if fam[0] == self.family.get_id():
if self.person == self.family.get_father_id(): if self.person == self.family.get_father_id():
@ -1381,9 +1381,9 @@ class FamilyView:
prev_date = "00000000" prev_date = "00000000"
for i in range(len(list)): for i in range(len(list)):
child_id = list[i] 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_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: if not birth:
continue continue
bday = birth.get_date_object() bday = birth.get_date_object()

View File

@ -169,7 +169,7 @@ class ImageSelect:
trans = self.db.start_transactions() trans = self.db.start_transactions()
for o_id in self.db.get_object_keys(): 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: if o.get_path() == filename:
already_imported = o already_imported = o
break break
@ -276,7 +276,7 @@ class Gallery(ImageSelect):
def on_drag_begin(self,obj,context): def on_drag_begin(self,obj,context):
if const.dnd_images: if const.dnd_images:
id = self.sel_obj.get_reference_id() 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() mtype = obj.get_mime_type()
name = Utils.thumb_path(self.db.get_save_path(),obj) name = Utils.thumb_path(self.db.get_save_path(),obj)
pix = gtk.gdk.pixbuf_new_from_file(name) pix = gtk.gdk.pixbuf_new_from_file(name)
@ -370,7 +370,7 @@ class Gallery(ImageSelect):
def add_thumbnail(self, photo): def add_thumbnail(self, photo):
"""Scale the image and add it to the IconList.""" """Scale the image and add it to the IconList."""
oid = photo.get_reference_id() 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): if self.canvas_list.has_key(oid):
(grp,item,text,x,y) = self.canvas_list[oid] (grp,item,text,x,y) = self.canvas_list[oid]
if x != self.cx or y != self.cy: if x != self.cx or y != self.cy:
@ -603,7 +603,7 @@ class Gallery(ImageSelect):
menu = gtk.Menu() menu = gtk.Menu()
menu.set_title(_("Media Object")) 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() mtype = object.get_mime_type()
progname = GrampsMime.get_application(mtype) progname = GrampsMime.get_application(mtype)
@ -620,21 +620,21 @@ class Gallery(ImageSelect):
def popup_view_photo(self, obj): def popup_view_photo(self, obj):
"""Open this picture in a picture viewer""" """Open this picture in a picture viewer"""
photo = obj.get_data('o') 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)) None))
def popup_edit_photo(self, obj): def popup_edit_photo(self, obj):
"""Open this picture in a picture editor""" """Open this picture in a picture editor"""
photo = obj.get_data('o') photo = obj.get_data('o')
if os.fork() == 0: 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()]) os.execvp(const.editor,[const.editor, obj.get_path()])
def popup_convert_to_private(self, obj): def popup_convert_to_private(self, obj):
"""Copy this picture into gramps private database instead of """Copy this picture into gramps private database instead of
leaving it as an external data object.""" leaving it as an external data object."""
photo = obj.get_data('o') 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, name = RelImage.import_media_object(object.get_path(),self.path,
object.get_id()) object.get_id())
object.set_path(name) object.set_path(name)
@ -665,7 +665,7 @@ class LocalMediaProperties:
self.child_windows = {} self.child_windows = {}
self.photo = photo self.photo = photo
self.db = parent.db 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) None)
self.alist = photo.get_attribute_list()[:] self.alist = photo.get_attribute_list()[:]
self.lists_changed = 0 self.lists_changed = 0
@ -1119,7 +1119,7 @@ class DeleteMediaQuery:
self.db.commit_family(p,trans) self.db.commit_family(p,trans)
for key in self.db.get_source_keys(): 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 = [] nl = []
change = 0 change = 0
for photo in p.get_media_list(): for photo in p.get_media_list():
@ -1132,7 +1132,7 @@ class DeleteMediaQuery:
self.db.commit_source(p,trans) self.db.commit_source(p,trans)
for key in self.db.get_place_id_keys(): 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 = [] nl = []
change = 0 change = 0
for photo in p.get_media_list(): for photo in p.get_media_list():

View File

@ -132,12 +132,12 @@ class Marriage:
mid = family.get_mother_id() mid = family.get_mother_id()
if fid: 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: else:
father = None father = None
if mid: 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: else:
mother = None mother = None
@ -393,11 +393,11 @@ class Marriage:
foo = pickle.loads(data[2]); foo = pickle.loads(data[2]);
for src in foo.get_source_references(): for src in foo.get_source_references():
base_id = src.get_base_id() 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) src.set_base_id(newbase)
place = foo.get_place_id() place = foo.get_place_id()
if place: 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.elist.insert(row,foo)
self.lists_changed = 1 self.lists_changed = 1
@ -425,7 +425,7 @@ class Marriage:
foo = pickle.loads(data[2]); foo = pickle.loads(data[2]);
for src in foo.get_source_references(): for src in foo.get_source_references():
base_id = src.get_base_id() 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) src.set_base_id(newbase)
self.alist.insert(row,foo) self.alist.insert(row,foo)
@ -471,7 +471,7 @@ class Marriage:
place_id = event.get_place_id() place_id = event.get_place_id()
if 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: else:
place_name = "" place_name = ""
iter = self.etree.add([const.display_fevent(event.get_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()) self.date_field.set_text(event.get_date())
place_id = event.get_place_id() place_id = event.get_place_id()
if 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: else:
place_name = u"" place_name = u""
self.place_field.set_text(place_name) self.place_field.set_text(place_name)
@ -687,7 +687,7 @@ class Marriage:
if len(event.get_source_references()) > 0: if len(event.get_source_references()) > 0:
psrc_ref = event.get_source_references()[0] psrc_ref = event.get_source_references()[0]
psrc_id = psrc_ref.get_base_id() 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_src_field.set_text(psrc.get_title())
self.event_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) self.event_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()])
else: else:
@ -706,7 +706,7 @@ class Marriage:
if len(attr.get_source_references()) > 0: if len(attr.get_source_references()) > 0:
psrc_ref = attr.get_source_references()[0] psrc_ref = attr.get_source_references()[0]
psrc_id = psrc_ref.get_base_id() 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_src_field.set_text(psrc.get_title())
self.attr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) self.attr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()])
else: else:
@ -723,8 +723,8 @@ class Marriage:
father_id = self.family.get_father_id() father_id = self.family.get_father_id()
mother_id = self.family.get_mother_id() mother_id = self.family.get_mother_id()
father = self.db.find_person_from_id(father_id) father = self.db.try_to_find_person_from_id(father_id)
mother = self.db.find_person_from_id(mother_id) mother = self.db.try_to_find_person_from_id(mother_id)
if father and mother: if father and mother:
name = _("%s and %s") % (father.get_primary_name().get_name(), name = _("%s and %s") % (father.get_primary_name().get_name(),
mother.get_primary_name().get_name()) mother.get_primary_name().get_name())
@ -744,8 +744,8 @@ class Marriage:
import AttrEdit import AttrEdit
father_id = self.family.get_father_id() father_id = self.family.get_father_id()
mother_id = self.family.get_mother_id() mother_id = self.family.get_mother_id()
father = self.db.find_person_from_id(father_id) father = self.db.try_to_find_person_from_id(father_id)
mother = self.db.find_person_from_id(mother_id) mother = self.db.try_to_find_person_from_id(mother_id)
if father and mother: if father and mother:
name = _("%s and %s") % (father.get_primary_name().get_name(), name = _("%s and %s") % (father.get_primary_name().get_name(),
mother.get_primary_name().get_name()) mother.get_primary_name().get_name())
@ -788,7 +788,7 @@ class Marriage:
text = string.strip(unicode(field.get_text())) text = string.strip(unicode(field.get_text()))
if text: if text:
if self.pmap.has_key(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: elif makenew:
place = RelLib.Place() place = RelLib.Place()
place.set_title(text) place.set_title(text)

View File

@ -177,7 +177,7 @@ class MediaView:
id = store.get_value(iter,1) 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 = mobj.get_mime_type()
type_name = Utils.get_mime_description(type) type_name = Utils.get_mime_description(type)
path = mobj.get_path() path = mobj.get_path()
@ -225,7 +225,7 @@ class MediaView:
store,iter = self.selection.get_selected() store,iter = self.selection.get_selected()
if iter: if iter:
id = store.get_value(iter,1) 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 self.obj = object
mime_type = object.get_mime_type() mime_type = object.get_mime_type()
@ -290,7 +290,7 @@ class MediaView:
list_store, iter = self.selection.get_selected() list_store, iter = self.selection.get_selected()
if iter: if iter:
id = list_store.get_value(iter,1) 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) ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
def on_delete_clicked(self,obj): def on_delete_clicked(self,obj):
@ -299,7 +299,7 @@ class MediaView:
return return
id = store.get_value(iter,1) 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): if self.is_object_used(mobj):
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree) ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree)
QuestionDialog(_('Delete Media Object?'), QuestionDialog(_('Delete Media Object?'),
@ -343,7 +343,7 @@ class MediaView:
if not iter: if not iter:
return return
if (const.dnd_images): 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() mtype = object.get_mime_type()
name = Utils.thumb_path(self.db.get_save_path(),object) name = Utils.thumb_path(self.db.get_save_path(),object)
pix = gtk.gdk.pixbuf_new_from_file(name) pix = gtk.gdk.pixbuf_new_from_file(name)

View File

@ -366,13 +366,13 @@ class PedigreeView:
childlist = find_children(self.active_person) childlist = find_children(self.active_person)
if len(childlist) == 1: 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: if child:
self.load_canvas(child) self.load_canvas(child)
elif len(childlist) > 1: elif len(childlist) > 1:
myMenu = gtk.Menu() myMenu = gtk.Menu()
for child_id in childlist: 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) cname = GrampsCfg.nameof(child)
menuitem = gtk.MenuItem(None) menuitem = gtk.MenuItem(None)
if find_children(child): if find_children(child):
@ -485,11 +485,11 @@ class PedigreeView:
if family != None: if family != None:
father_id = family.get_father_id() father_id = family.get_father_id()
if father_id != None: 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) self.find_tree(father,(2*index)+1,depth+1,list,frel)
mother_id = family.get_mother_id() mother_id = family.get_mother_id()
if mother_id != None: 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) self.find_tree(mother,(2*index)+2,depth+1,list,mrel)
def on_canvas1_event(self,obj,event): def on_canvas1_event(self,obj,event):

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # 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 # 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 # 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 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Standard python modules # Standard python modules
@ -127,7 +129,7 @@ class PeopleModel(gtk.GenericTreeModel):
for person_id in self.db.get_person_keys(): 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()) surname = unicode(person.get_primary_name().get_surname())
if self.sname_sub.has_key(surname): if self.sname_sub.has_key(surname):
@ -344,7 +346,7 @@ class PeopleModel(gtk.GenericTreeModel):
if event: if event:
place_id = event.get_place_id() place_id = event.get_place_id()
if 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"" return u""
def column_death_place(self,data): def column_death_place(self,data):
@ -353,7 +355,7 @@ class PeopleModel(gtk.GenericTreeModel):
if event: if event:
place_id = event.get_place_id() place_id = event.get_place_id()
if 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"" return u""
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]

View File

@ -198,7 +198,7 @@ class PlaceView:
for place in mlist: for place in mlist:
used = 0 used = 0
for key in self.db.get_person_keys(): 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 = [] event_list = []
for e in [p.get_birth_id(),p.get_death_id()] + p.get_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) event = self.db.find_event_from_id(e)

View File

@ -88,8 +88,8 @@ class SelectChild:
self.add_child = self.xml.get_widget("childlist") self.add_child = self.xml.get_widget("childlist")
if (self.family): if (self.family):
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())
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 father != None: if father != None:
fname = father.get_primary_name().get_name() fname = father.get_primary_name().get_name()
@ -300,13 +300,13 @@ class SelectChild:
self.family.add_child_id(select_child.get_id()) self.family.add_child_id(select_child.get_id())
mrel = const.child_relations.find_value(self.mrel.get_text()) 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 mother and mother.get_gender() != RelLib.Person.female:
if mrel == "Birth": if mrel == "Birth":
mrel = "Unknown" mrel = "Unknown"
frel = const.child_relations.find_value(self.frel.get_text()) 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 father and father.get_gender() !=RelLib. Person.male:
if frel == "Birth": if frel == "Birth":
frel = "Unknown" frel = "Unknown"
@ -393,8 +393,8 @@ class EditRel:
Utils.set_titles(self.top,self.xml.get_widget('title'), Utils.set_titles(self.top,self.xml.get_widget('title'),
_('Relationships of %s') % name) _('Relationships of %s') % name)
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())
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 father: if father:
fname = father.get_primary_name().get_name() fname = father.get_primary_name().get_name()
@ -436,13 +436,13 @@ class EditRel:
def on_ok_clicked(self,obj): def on_ok_clicked(self,obj):
mrel = const.child_relations.find_value(self.mentry.get_text()) 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 mother and mother.get_gender() != RelLib.Person.female:
if mrel == "Birth": if mrel == "Birth":
mrel = "Unknown" mrel = "Unknown"
frel = const.child_relations.find_value(self.fentry.get_text()) 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 father and father.get_gender() !=RelLib. Person.male:
if frel == "Birth": if frel == "Birth":
frel = "Unknown" frel = "Unknown"

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # 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 # 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 # 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 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
# #
# Written by Alex Roitman, # Written by Alex Roitman,
# largely based on the MediaView and SelectPerson by Don Allingham # largely based on the MediaView and SelectPerson by Don Allingham
@ -98,7 +100,7 @@ class SelectObject:
self.object_model.new_model() self.object_model.new_model()
for key in self.db.get_object_keys(): 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() title = object.get_description()
the_id = object.get_id() the_id = object.get_id()
the_type = Utils.get_mime_description(object.get_mime_type()) the_type = Utils.get_mime_description(object.get_mime_type())
@ -115,7 +117,7 @@ class SelectObject:
return return
data = self.object_model.get_data(iter,range(self.ncols)) data = self.object_model.get_data(iter,range(self.ncols))
the_id = data[4] 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()) the_type = Utils.get_mime_description(object.get_mime_type())
path = object.get_path() path = object.get_path()
@ -148,7 +150,7 @@ class SelectObject:
if iter: if iter:
data = self.object_model.get_data(iter,range(self.ncols)) data = self.object_model.get_data(iter,range(self.ncols))
the_id = data[4] 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: else:
return_value = None return_value = None
self.top.destroy() self.top.destroy()

View File

@ -229,7 +229,7 @@ class SourceView:
if sref.get_base_id() == source.get_id(): if sref.get_base_id() == source.get_id():
return 1 return 1
for p_id in self.db.get_object_keys(): 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(): for sref in p.get_source_references():
if sref.get_base_id() == source.get_id(): if sref.get_base_id() == source.get_id():
return 1 return 1

View File

@ -162,7 +162,7 @@ class SourceSelector:
self.model.clear() self.model.clear()
for s in self.list: for s in self.list:
base_id = s.get_base_id() 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() iter = self.model.append()
self.model.set(iter,0,base_id,1,base.get_title()) self.model.set(iter,0,base_id,1,base.get_title())
@ -244,7 +244,7 @@ class SourceTab:
for s in self.list: for s in self.list:
base_id = s.get_base_id() base_id = s.get_base_id()
iter = self.model.append() 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()) self.model.set(iter,0,base_id,1,base.get_title())
if self.list: if self.list:
Utils.bold_label(self.parent.sources_label) Utils.bold_label(self.parent.sources_label)
@ -334,7 +334,7 @@ class SourceEditor:
self.pub_field = self.get_widget("spubinfo") self.pub_field = self.get_widget("spubinfo")
if self.source_ref: 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: else:
self.active_source = None self.active_source = None
@ -415,7 +415,7 @@ class SourceEditor:
scom = self.get_widget("scomment") scom = self.get_widget("scomment")
scom.get_buffer().set_text(self.source_ref.get_comments()) 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 self.active_source = src
if src: if src:
self.author_field.set_text(src.get_author()) self.author_field.set_text(src.get_author())
@ -431,7 +431,7 @@ class SourceEditor:
self.list = [] self.list = []
self.active_source = sel self.active_source = sel
for src_id in keys: 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 = gtk.Label("%s [%s]" % (src.get_title(),src.get_id()))
l.show() l.show()
l.set_alignment(0,0.5) l.set_alignment(0,0.5)
@ -453,7 +453,7 @@ class SourceEditor:
def on_sourceok_clicked(self,obj): 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()) self.source_ref.set_base_id(self.active_source.get_id())
date = unicode(self.get_widget("sdate").get_text()) date = unicode(self.get_widget("sdate").get_text())

View File

@ -123,8 +123,8 @@ def family_name(family,db):
"""Builds a name for the family from the parents names""" """Builds a name for the family from the parents names"""
father_id = family.get_father_id() father_id = family.get_father_id()
mother_id = family.get_mother_id() mother_id = family.get_mother_id()
father = db.find_person_from_id(father_id,None) father = db.try_to_find_person_from_id(father_id,None)
mother = db.find_person_from_id(mother_id,None) mother = db.try_to_find_person_from_id(mother_id,None)
if father and mother: if father and mother:
fname = father.get_primary_name().get_name() fname = father.get_primary_name().get_name()
mname = mother.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""" """Builds a name for the family from the parents names"""
father_id = family.get_father_id() father_id = family.get_father_id()
mother_id = family.get_mother_id() mother_id = family.get_mother_id()
father = db.find_person_from_id(father_id,None) father = db.try_to_find_person_from_id(father_id,None)
mother = db.find_person_from_id(mother_id,None) mother = db.try_to_find_person_from_id(mother_id,None)
if father and mother: if father and mother:
fname = father.get_primary_name().get_upper_name() fname = father.get_primary_name().get_upper_name()
mname = mother.get_primary_name().get_upper_name() mname = mother.get_primary_name().get_upper_name()

View File

@ -70,7 +70,7 @@ class WitnessTab:
if s.get_type() == RelLib.Event.ID: if s.get_type() == RelLib.Event.ID:
id = s.get_value() id = s.get_value()
if self.db.has_person_id(id): 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: else:
n = _('Unknown') n = _('Unknown')
self.model.add([n,s.get_value()],s) self.model.add([n,s.get_value()],s)
@ -149,7 +149,7 @@ class WitnessEditor:
if self.ref.get_type(): if self.ref.get_type():
self.in_db.set_active(1) self.in_db.set_active(1)
self.idval = self.ref.get_value() 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()) self.name.set_text(person.get_primary_name().get_regular_name())
else: else:
self.name.set_text(self.ref.get_value()) self.name.set_text(self.ref.get_value())

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # 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 # 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 # it under the terms of the GNU General Public License as published by
@ -379,7 +379,7 @@ class XmlWriter:
self.g.write(" <objects>\n") self.g.write(" <objects>\n")
objList.sort () objList.sort ()
for key in self.db.get_object_keys(): 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.write_object(object)
self.g.write(" </objects>\n") self.g.write(" </objects>\n")
@ -493,7 +493,7 @@ class XmlWriter:
self.g.write('%s</lds_ord>\n' % sp) self.g.write('%s</lds_ord>\n' % sp)
def dump_source_ref(self,source_ref,index=1): 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: if source:
p = source_ref.get_page() p = source_ref.get_page()
c = source_ref.get_comments() c = source_ref.get_comments()

View File

@ -356,7 +356,7 @@ class Gramps:
def undo(self,*args): def undo(self,*args):
self.db.undo() self.db.undo()
if self.active_person: 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.change_active_person(p)
self.place_view.change_db(self.db) self.place_view.change_db(self.db)
self.people_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) hotkey = "_%s" % chr(ord('a')+num-11)
elif num >= 21: elif num >= 21:
break 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]" % item = gtk.MenuItem("%s. %s [%s]" %
(hotkey,person.get_primary_name().get_name(),pid)) (hotkey,person.get_primary_name().get_name(),pid))
item.connect("activate",self.back_clicked,num) item.connect("activate",self.back_clicked,num)
@ -1091,7 +1091,7 @@ class Gramps:
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def remove_clicked(): def remove_clicked():
# File is lost => remove all references and the object itself # 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(): for p in self.db.get_family_id_map().values():
nl = p.get_media_list() nl = p.get_media_list()
for o in nl: for o in nl:
@ -1147,13 +1147,13 @@ class Gramps:
name = choose.get_filename() name = choose.get_filename()
if os.path.isfile(name): if os.path.isfile(name):
RelImage.import_media_object(name,filename,base) 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) object.set_path(name)
choose.destroy() choose.destroy()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
for ObjectId in self.db.get_object_keys(): 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: if 0:
oldfile = object.get_path() oldfile = object.get_path()
(base,ext) = os.path.splitext(os.path.basename(oldfile)) (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 self.active_person.get_id() == family.get_father_id():
if family.get_mother_id() == None: if family.get_mother_id() == None:
for child_id in family.get_child_id_list(): 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()) child.remove_parent_family_id(family.get_id())
self.db.commit_person(child,trans) self.db.commit_person(child,trans)
self.db.delete_family(family.get_id(),trans) self.db.delete_family(family.get_id(),trans)
@ -1297,7 +1297,7 @@ class Gramps:
else: else:
if family.get_father_id() == None: if family.get_father_id() == None:
for child_id in family.get_child_id_list(): 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) child.remove_parent_family_id(family)
self.db.commit_person(child,trans) self.db.commit_person(child,trans)
self.db.delete_family(family,trans) self.db.delete_family(family,trans)
@ -1317,7 +1317,7 @@ class Gramps:
self.db.remove_person_id(id, trans) self.db.remove_person_id(id, trans)
if self.hindex >= 0: 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: else:
self.change_active_person(None) self.change_active_person(None)
self.db.add_transaction(trans,_("Delete Person (%s)") % n) self.db.add_transaction(trans,_("Delete Person (%s)") % n)
@ -1342,8 +1342,7 @@ class Gramps:
self.modify_statusbar() self.modify_statusbar()
elif self.active_person == None or \ elif self.active_person == None or \
person.get_id() != self.active_person.get_id(): person.get_id() != self.active_person.get_id():
self.active_person = self.db.find_person_from_id(person.get_id(), self.active_person = self.db.try_to_find_person_from_id(person.get_id())
None)
self.modify_statusbar() self.modify_statusbar()
self.set_buttons(1) self.set_buttons(1)
if person: if person:
@ -1369,8 +1368,7 @@ class Gramps:
self.backbtn.set_sensitive(0) self.backbtn.set_sensitive(0)
self.back.set_sensitive(0) self.back.set_sensitive(0)
else: else:
self.active_person = self.db.find_person_from_id(person.get_id(), self.active_person = self.db.try_to_find_person_from_id(person.get_id())
None)
self.set_buttons(1) self.set_buttons(1)
def modify_statusbar(self): def modify_statusbar(self):
@ -1674,7 +1672,7 @@ class Gramps:
def bookmark_callback(self,obj,person_id): def bookmark_callback(self,obj,person_id):
old_person = self.active_person 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: try:
self.change_active_person(person) self.change_active_person(person)
self.update_display(0) self.update_display(0)