From 3fef3dd32ee2d2a1f18d760aa2bfb609b2372d5f Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 15 Feb 2004 16:45:33 +0000 Subject: [PATCH] * src/plugins/RelCalc.py: Handle IDs properly * src/Relationship.py: Handle IDs properly * src/home.png: added new default person icon svn: r2838 --- src/Relationship.py | 60 +++++++++++++++++++++--------------------- src/plugins/RelCalc.py | 15 ++++++----- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/Relationship.py b/src/Relationship.py index c34d07207..c36629174 100644 --- a/src/Relationship.py +++ b/src/Relationship.py @@ -265,19 +265,19 @@ class RelationshipCalculator: return ("spouse",[]) try: - self.apply_filter(orig_person,0,firstList,firstMap) - self.apply_filter(other_person,0,secondList,secondMap) + self.apply_filter(orig_person.get_id(),0,firstList,firstMap) + self.apply_filter(other_person.get_id(),0,secondList,secondMap) except RuntimeError,msg: return (_("Relationship loop detected"),None) - for person in firstList: - if person in secondList: - new_rank = firstMap[person.get_id()] + for person_id in firstList: + if person_id in secondList: + new_rank = firstMap[person_id] if new_rank < rank: rank = new_rank - common = [ person ] + common = [ person_id ] elif new_rank == rank: - common.append(person) + common.append(person_id) firstRel = -1 secondRel = -1 @@ -285,17 +285,17 @@ class RelationshipCalculator: length = len(common) if length == 1: - person = common[0] - secondRel = firstMap[person.get_id()] - firstRel = secondMap[person.get_id()] + person_id = common[0] + secondRel = firstMap[person_id] + firstRel = secondMap[person_id] elif length == 2: - p1 = common[0] - secondRel = firstMap[p1.get_id()] - firstRel = secondMap[p1.get_id()] + person_id = common[0] + secondRel = firstMap[person_id] + firstRel = secondMap[person_id] elif length > 2: - person = common[0] - secondRel = firstMap[person.get_id()] - firstRel = secondMap[person.get_id()] + person_id = common[0] + secondRel = firstMap[person_id] + firstRel = secondMap[person_id] if firstRel == -1: return ("",[]) @@ -348,14 +348,14 @@ class RelationshipCalculator: self.apply_filter(orig_person,0,firstList,firstMap) self.apply_filter(other_person,0,secondList,secondMap) - for person in firstList: - if person in secondList: - new_rank = firstMap[person.get_id()] + for person_id in firstList: + if person_id in secondList: + new_rank = firstMap[person_id] if new_rank < rank: rank = new_rank - common = [ person ] + common = [ person_id ] elif new_rank == rank: - common.append(person) + common.append(person_id) firstRel = -1 secondRel = -1 @@ -363,17 +363,17 @@ class RelationshipCalculator: length = len(common) if length == 1: - person = common[0] - secondRel = firstMap[person.get_id()] - firstRel = secondMap[person.get_id()] + person_id = common[0] + secondRel = firstMap[person_id] + firstRel = secondMap[person_id] elif length == 2: - p1 = common[0] - secondRel = firstMap[p1.get_id()] - firstRel = secondMap[p1.get_id()] + person_id = common[0] + secondRel = firstMap[person_id] + firstRel = secondMap[person_id] elif length > 2: - person = common[0] - secondRel = firstMap[person.get_id()] - firstRel = secondMap[person.get_id()] + person_id = common[0] + secondRel = firstMap[person_id] + firstRel = secondMap[person_id] if firstRel == 0: if secondRel == 0: diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index 8359b6751..4210fa773 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -69,8 +69,8 @@ class RelCalc: def __init__(self,database,person): self.person = person self.db = database - self.RelClass = Plugins.relationship_class(database) - self.relationship = self.RelClass.get_relationship + self.RelClass = Plugins.relationship_class + self.relationship = self.RelClass(database) base = os.path.dirname(__file__) glade_file = "%s/relcalc.glade" % base @@ -112,23 +112,24 @@ class RelCalc: id = self.clist.get_object(iter) other_person = self.db.get_person(id) - (rel_string,common) = self.relationship(self.person,other_person) + (rel_string,common) = self.relationship.get_relationship(self.person,other_person) length = len(common) if length == 1: - person = common[0] + person = self.db.find_person_from_id(common[0]) name = person.get_primary_name().get_regular_name() commontext = " " + _("Their common ancestor is %s.") % name elif length == 2: - p1 = common[0] - p2 = common[1] + p1 = self.db.find_person_from_id(common[0]) + p2 = self.db.find_person_from_id(common[1]) commontext = " " + _("Their common ancestors are %s and %s.") % \ (p1.get_primary_name().get_regular_name(),\ p2.get_primary_name().get_regular_name()) elif length > 2: index = 0 commontext = " " + _("Their common ancestors are : ") - for person in common: + for person_id in common: + person = self.db.find_person_form_id(person_id) if index != 0: commontext = commontext + ", " commontext = commontext + person.get_primary_name().get_regular_name()