From 55a76f77e1df1b3d7e5d31fc13257368090ac459 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sat, 21 Aug 2004 18:13:18 +0000 Subject: [PATCH] * src/ReadGedcom.py (parse_record): Get objects from handles; (handle_source): Refer to handle, not the object; (parse_source): Use gramps id (not handle) to form the title. * src/GrampsDbBase.py (get_person_from_handle): Typo; (find_event_from_handle): Correctly create new event if not found. * src/Sources.py (draw): Correctly sort, use gramps id when displaying sources; (redraw): Use gramps id in the list view. svn: r3461 --- ChangeLog | 9 +++++++++ src/GrampsDbBase.py | 24 ++++++++++++++---------- src/ReadGedcom.py | 18 +++++++++++------- src/Sources.py | 8 ++++---- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8edc26a23..2481cde63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-08-21 Alex Roitman + * src/ReadGedcom.py (parse_record): Get objects from handles; + (handle_source): Refer to handle, not the object; + (parse_source): Use gramps id (not handle) to form the title. + * src/GrampsDbBase.py (get_person_from_handle): Typo; + (find_event_from_handle): Correctly create new event if not found. + * src/Sources.py (draw): Correctly sort, use gramps id when + displaying sources; (redraw): Use gramps id in the list view. + 2004-08-20 Don Allingham * src/gramps_main.py: update family display after EditPerson * src/EditPerson.py: fix callback diff --git a/src/GrampsDbBase.py b/src/GrampsDbBase.py index b7f8259c1..537f875ea 100644 --- a/src/GrampsDbBase.py +++ b/src/GrampsDbBase.py @@ -261,7 +261,7 @@ class GrampsDbBase: def get_person_from_handle(self,val): """finds a Person in the database from the passed gramps' ID. - If no such Person exists, a new Person is added to the database.""" + If no such Person exists, None is returned.""" data = self.person_map.get(str(val)) if data: @@ -302,8 +302,8 @@ class GrampsDbBase: return None def get_event_from_handle(self,handle): - """finds a Place in the database from the passed gramps' ID. - If no such Place exists, None is returned.""" + """finds a Event in the database from the passed gramps' ID. + If no such Event exists, None is returned.""" data = self.event_map.get(str(handle)) if data: @@ -313,8 +313,8 @@ class GrampsDbBase: return None def get_family_from_handle(self,handle): - """finds a Place in the database from the passed gramps' ID. - If no such Place exists, None is returned.""" + """finds a Family in the database from the passed gramps' ID. + If no such Family exists, None is returned.""" data = self.family_map.get(str(handle)) if data: @@ -358,16 +358,20 @@ class GrampsDbBase: def find_event_from_handle(self,val): """ - Finds a Family in the database from the passed GRAMPS ID. - If no such Family exists, a new Family is added to the database. + Finds a Event in the database from the passed GRAMPS ID. + If no such Event exists, a new Event is added to the database. """ + event = Event() data = self.event_map.get(str(val)) if data: - event = Event() event.unserialize(data) - return event else: - return None + event.set_handle(val) + if transaction: + transaction.add(EVENT_KEY,val,None) + self.event_map[str(val)] = event.serialize() + self.emap_index = self.emap_index + 1 + return event def find_object_from_handle(self,handle,transaction): """ diff --git a/src/ReadGedcom.py b/src/ReadGedcom.py index ebfc9a889..13f182f6c 100644 --- a/src/ReadGedcom.py +++ b/src/ReadGedcom.py @@ -454,7 +454,7 @@ class GedcomParser: if note: self.source.set_note(note) if not self.source.get_title(): - self.source.set_title("No title - ID %s" % self.source.get_handle()) + self.source.set_title("No title - ID %s" % self.source.get_gramps_id()) self.db.commit_source(self.source, self.trans) self.backup() return @@ -501,17 +501,21 @@ class GedcomParser: self.family = self.find_or_create_family(matches[1]) self.parse_family() if self.addr != None: - father = self.family.get_father_handle() + father_handle = self.family.get_father_handle() + father = self.db.get_person_from_handle(father_handle) if father: father.add_address(self.addr) self.db.commit_person(father, self.trans) - mother = self.family.get_mother_handle() + mother_handle = self.family.get_mother_handle() + mother = self.db.get_person_from_handle(mother_handle) if mother: mother.add_address(self.addr) self.db.commit_person(mother, self.trans) - for child in self.family.get_child_handle_list(): - child.add_address(self.addr) - self.db.commit_person(child, self.trans) + for child_handle in self.family.get_child_handle_list(): + child = self.db.get_person_from_handle(child_handle) + if child: + child.add_address(self.addr) + self.db.commit_person(child, self.trans) self.db.commit_family(self.family, self.trans) del self.family elif matches[2] == "INDI": @@ -1751,7 +1755,7 @@ class GedcomParser: s.set_note(matches[2] + self.parse_continue_data(level)) self.ignore_sub_junk(level+1) else: - source_ref.set_base_handle(self.find_or_create_source(matches[2][1:-1])) + source_ref.set_base_handle(self.find_or_create_source(matches[2][1:-1]).get_handle()) self.parse_source_reference(source_ref,level) return source_ref diff --git a/src/Sources.py b/src/Sources.py index 774624def..0031e6aa2 100644 --- a/src/Sources.py +++ b/src/Sources.py @@ -243,9 +243,9 @@ class SourceTab: self.model.clear() for s in self.list: base_handle = s.get_base_handle() - iter = self.model.append() base = self.db.get_source_from_handle(base_handle) - self.model.set(iter,0,base_handle,1,base.get_title()) + iter = self.model.append() + self.model.set(iter,0,base.get_gramps_id(),1,base.get_title()) if self.list: Utils.bold_label(self.parent.sources_label) else: @@ -426,14 +426,14 @@ class SourceEditor: self.pub_field.set_text("") keys = self.db.get_source_handles() - keys.sort(self.db.sortbysource) + keys.sort(self.db._sortbysource) sel_child = None self.list = [] self.active_source = sel for src_id in keys: src = self.db.get_source_from_handle(src_id) - l = gtk.Label("%s [%s]" % (src.get_title(),src.get_handle())) + l = gtk.Label("%s [%s]" % (src.get_title(),src.get_gramps_id())) l.show() l.set_alignment(0,0.5) c = gtk.ListItem()