From e4b2a9f56560ccecbb48ae5c77f57cbcf760a830 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Fri, 19 May 2006 00:39:22 +0000 Subject: [PATCH] (commit_*): update custom type sets on commit. svn: r6719 --- ChangeLog | 2 +- src/GrampsDb/_GrampsBSDDB.py | 2 -- src/GrampsDb/_GrampsDbBase.py | 63 +++++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81909a83b..f055add48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ unused secondary tables; add more custom type holders. * src/GrampsDb/_GrampsDbBase.py (GrampsDbBase.__init__): Add more custom type holders. + (commit_*): update custom type sets on commit. * src/DisplayTabs/_BackRefList.py (edit_button_clicked): Typo. * src/DataViews/_RepositoryView.py (edit, on_double_click): Catch exception. @@ -14,7 +15,6 @@ * src/GrampsDb/_WriteXML.py (write_bookmarks): Add method to write new bookmarks. (XmlWriter.write_xml_data): Do not export name groups. - * src/GrampsDb/_ReadXML.py (start_bmark): Parse new bookmarks * INSTALL: Clarify; list build-dependencies. * src/GrampsDb/_ReadGrdb.py: Update progress. diff --git a/src/GrampsDb/_GrampsBSDDB.py b/src/GrampsDb/_GrampsBSDDB.py index 9c599200e..3dbb991fd 100644 --- a/src/GrampsDb/_GrampsBSDDB.py +++ b/src/GrampsDb/_GrampsBSDDB.py @@ -397,7 +397,6 @@ class GrampsBSDDB(GrampsDbBase): self.individual_event_names = set(self.metadata.get('pevent_names',[])) self.family_attributes = set(self.metadata.get('fattr_names',[])) self.individual_attributes = set(self.metadata.get('pattr_names',[])) - # These are not hooked up yet: self.child_ref_types = set(self.metadata.get('child_refs',[])) self.family_rel_types = set(self.metadata.get('family_rels',[])) self.event_role_names = set(self.metadata.get('event_roles',[])) @@ -824,7 +823,6 @@ class GrampsBSDDB(GrampsDbBase): self.metadata['pevent_names'] = list(self.individual_event_names) self.metadata['fattr_names'] = list(self.family_attributes) self.metadata['pattr_names'] = list(self.individual_attributes) - # These are not hooked up yet: self.metadata['child_refs'] = list(self.child_ref_types) self.metadata['family_rels'] = list(self.family_rel_types) self.metadata['event_roles'] = list(self.event_role_names) diff --git a/src/GrampsDb/_GrampsDbBase.py b/src/GrampsDb/_GrampsDbBase.py index 275c2c019..936f08ebf 100644 --- a/src/GrampsDb/_GrampsDbBase.py +++ b/src/GrampsDb/_GrampsDbBase.py @@ -224,9 +224,6 @@ class GrampsDbBase(GrampsDBCallback): self.individual_attributes = set() self.family_attributes = set() self.marker_names = set() - - # FIXME: TODO: These are just added here at the moment. - # They need to be hooked up on commits self.child_ref_types = set() self.family_rel_types = set() self.event_role_names = set() @@ -234,7 +231,6 @@ class GrampsDbBase(GrampsDBCallback): self.repository_types = set() self.source_media_types = set() self.url_types = set() - # END FIXME self.set_person_id_prefix(Config.get(Config.IPREFIX)) self.set_object_id_prefix(Config.get(Config.OPREFIX)) @@ -449,11 +445,28 @@ class GrampsDbBase(GrampsDBCallback): else: self.genderStats.count_person(person) - for attr in person.attribute_list: - self.individual_attributes.add(str(attr.type)) + self.individual_attributes.update( + [str(attr.type) for attr in person.attribute_list + if attr.type.is_custom()]) + + if person.marker.is_custom(): + self.marker_names.add(str(person.marker)) + + eref_list = [eref for eref in (person.event_ref_list + + [person.birth_ref,person.death_ref]) + if eref] + + self.event_role_names.update( + [str(eref.role) for eref in eref_list if eref.role.is_custom()]) + + self.name_types.update([str(name.type) + for name in ([person.primary_name] + + person.alternate_names) + if name.type.is_custom()]) + + self.url_types.update([str(url.type) for url in person.urls + if url.type.is_custom()]) - self.marker_names.add(str(person.marker)) - def commit_media_object(self, obj, transaction, change_time=None): """ Commits the specified MediaObject to the database, storing the changes @@ -474,6 +487,11 @@ class GrampsDbBase(GrampsDBCallback): transaction.source_update, transaction.source_add, transaction, change_time) + self.source_media_types.update( + [str(ref.media_type) for ref in source.reporef_list + if ref.media_type.is_custom()]) + + def commit_place(self, place, transaction, change_time=None): """ Commits the specified Place to the database, storing the changes @@ -484,6 +502,9 @@ class GrampsDbBase(GrampsDBCallback): transaction.place_update, transaction.place_add, transaction, change_time) + self.url_types.update([str(url.type) for url in place.urls + if url.type.is_custom()]) + def commit_personal_event(self, event, transaction, change_time=None): if event.type.is_custom(): self.individual_event_names.add(str(event.type)) @@ -513,8 +534,24 @@ class GrampsDbBase(GrampsDBCallback): transaction.family_update, transaction.family_add, transaction, change_time) - for attr in family.attribute_list: - self.family_attributes.add(str(attr.type)) + self.family_attributes.update( + [str(attr.type) for attr in family.attribute_list + if attr.type.is_custom()]) + + self.child_ref_types.update( + [str(ref.frel) for ref in family.child_ref_list + if ref.frel.is_custom()]) + + self.child_ref_types.update( + [str(ref.mrel) for ref in family.child_ref_list + if ref.mrel.is_custom()]) + + self.event_role_names.update( + [str(eref.role) for eref in family.event_ref_list + if eref.role.is_custom()]) + + if family.type.is_custom(): + self.family_rel_types.add(str(family.type)) def commit_repository(self, repository, transaction, change_time=None): """ @@ -527,6 +564,12 @@ class GrampsDbBase(GrampsDBCallback): transaction.repository_add, transaction, change_time) + if repository.type.is_custom(): + self.repository_types.add(str(repository.type)) + + self.url_types.update([str(url.type) for url in repository.urls + if url.type.is_custom()]) + def find_next_person_gramps_id(self): """ Returns the next available GRAMPS' ID for a Person object based