From f1b13b49c563184ef826ef474e0ef63682471bd9 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 29 Jun 2005 15:23:15 +0000 Subject: [PATCH] * src/GrampsDbBase.py: move gender stats handling to the commit_person task, instead of trying to handle it in the Person() class * src/RelLib.py: removal of genderstats handling svn: r4890 --- gramps2/ChangeLog | 5 +++++ gramps2/src/GrampsDbBase.py | 13 +++++++++++-- gramps2/src/RelLib.py | 13 ------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index b71191b25..1f370c386 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2005-06-29 Don Allingham + * src/GrampsDbBase.py: move gender stats handling to the commit_person + task, instead of trying to handle it in the Person() class + * src/RelLib.py: removal of genderstats handling + 2005-06-28 Don Allingham * src/EditPerson.py: parse date correctly on edit * src/ReadGedcom.py: load previously used title properly into diff --git a/gramps2/src/GrampsDbBase.py b/gramps2/src/GrampsDbBase.py index 3e3b465f7..33cf37e49 100644 --- a/gramps2/src/GrampsDbBase.py +++ b/gramps2/src/GrampsDbBase.py @@ -279,6 +279,16 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): old_data = self.person_map.get(handle) if transaction != None: transaction.add(PERSON_KEY,handle,old_data) + + if old_data: + old_person = Person(old_data) + if (old_data[2] != person.gender or + old_data[3].first_name != person.primary_name.first_name): + self.genderStats.uncount_person(old_person) + self.genderStats.count_person(person,self) + else: + self.genderStats.count_person(person,self) + self.person_map[handle] = person.serialize() if old_data: self.emit('person-update',([handle],)) @@ -462,8 +472,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): data = self.person_map.get(str(val)) if data: - person = Person() - person.unserialize(data) + person = Person(data) return person return None diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index dee29a7a5..966518bc5 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -939,7 +939,6 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): # We hold a reference to the GrampsDB so that we can maintain # its genderStats. It doesn't get set here, but from # GenderStats.count_person. - self.db = None def serialize(self): """ @@ -1134,12 +1133,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): @param name: L{Name} to be assigned to the person @type name: L{Name} """ - db = self.db - if db: - db.genderStats.uncount_person (self) self.primary_name = name - if db: - db.genderStats.count_person (self, db) def get_primary_name(self): """ @@ -1233,13 +1227,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase): Person.UNKNOWN @type gender: int """ - # if the db object has been assigned, update the - # genderStats of the database - if self.db: - self.db.genderStats.uncount_person (self) self.gender = gender - if self.db: - self.db.genderStats.count_person (self, self.db) def get_gender(self) : """ @@ -4058,7 +4046,6 @@ class GenderStats: if not person: return # Let the Person do their own counting later - person.db = db name = self._get_key (person) if not name: