From 4c47a396a81105a5e061bc2d2a14343ba86b7486 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 14 Jun 2015 09:56:58 -0400 Subject: [PATCH] 8634: DB-API Database backend doesn't compute inverse filters correctly --- gramps/gen/proxy/living.py | 81 ----------------------- gramps/gen/proxy/private.py | 80 ---------------------- gramps/gen/proxy/referencedbyselection.py | 81 ----------------------- gramps/plugins/quickview/filterbyname.py | 74 ++++++++++++++------- 4 files changed, 50 insertions(+), 266 deletions(-) diff --git a/gramps/gen/proxy/living.py b/gramps/gen/proxy/living.py index 70e9e5e3d..50175be87 100644 --- a/gramps/gen/proxy/living.py +++ b/gramps/gen/proxy/living.py @@ -77,87 +77,6 @@ class LivingProxyDb(ProxyDbBase): else: self.current_date = None self.years_after_death = years_after_death - # need to update _tables with these functions - self._tables['Person'].update( - { - "handle_func": self.get_person_from_handle, - "gramps_id_func": self.get_person_from_gramps_id, - "class_func": Person, - "cursor_func": self.get_person_cursor, - "handles_func": self.get_person_handles, - }) - self._tables['Family'].update( - { - "handle_func": self.get_family_from_handle, - "gramps_id_func": self.get_family_from_gramps_id, - "class_func": Family, - "cursor_func": self.get_family_cursor, - "handles_func": self.get_family_handles, - }) - self._tables['Source'].update( - { - "handle_func": self.get_source_from_handle, - "gramps_id_func": self.get_source_from_gramps_id, - "class_func": Source, - "cursor_func": self.get_source_cursor, - "handles_func": self.get_source_handles, - }) - self._tables['Citation'].update( - { - "handle_func": self.get_citation_from_handle, - "gramps_id_func": self.get_citation_from_gramps_id, - "class_func": Citation, - "cursor_func": self.get_citation_cursor, - "handles_func": self.get_citation_handles, - }) - self._tables['Event'].update( - { - "handle_func": self.get_event_from_handle, - "gramps_id_func": self.get_event_from_gramps_id, - "class_func": Event, - "cursor_func": self.get_event_cursor, - "handles_func": self.get_event_handles, - }) - self._tables['Media'].update( - { - "handle_func": self.get_object_from_handle, - "gramps_id_func": self.get_object_from_gramps_id, - "class_func": MediaObject, - "cursor_func": self.get_media_cursor, - "handles_func": self.get_media_object_handles, - }) - self._tables['Place'].update( - { - "handle_func": self.get_place_from_handle, - "gramps_id_func": self.get_place_from_gramps_id, - "class_func": Place, - "cursor_func": self.get_place_cursor, - "handles_func": self.get_place_handles, - }) - self._tables['Repository'].update( - { - "handle_func": self.get_repository_from_handle, - "gramps_id_func": self.get_repository_from_gramps_id, - "class_func": Repository, - "cursor_func": self.get_repository_cursor, - "handles_func": self.get_repository_handles, - }) - self._tables['Note'].update( - { - "handle_func": self.get_note_from_handle, - "gramps_id_func": self.get_note_from_gramps_id, - "class_func": Note, - "cursor_func": self.get_note_cursor, - "handles_func": self.get_note_handles, - }) - self._tables['Tag'].update( - { - "handle_func": self.get_tag_from_handle, - "gramps_id_func": None, - "class_func": Tag, - "cursor_func": self.get_tag_cursor, - "handles_func": self.get_tag_handles, - }) def get_person_from_handle(self, handle): """ diff --git a/gramps/gen/proxy/private.py b/gramps/gen/proxy/private.py index b1f873b1c..5ee51d4d1 100644 --- a/gramps/gen/proxy/private.py +++ b/gramps/gen/proxy/private.py @@ -56,86 +56,6 @@ class PrivateProxyDb(ProxyDbBase): Create a new PrivateProxyDb instance. """ ProxyDbBase.__init__(self, db) - self._tables['Person'].update( - { - "handle_func": self.get_person_from_handle, - "gramps_id_func": self.get_person_from_gramps_id, - "class_func": Person, - "cursor_func": self.get_person_cursor, - "handles_func": self.get_person_handles, - }) - self._tables['Family'].update( - { - "handle_func": self.get_family_from_handle, - "gramps_id_func": self.get_family_from_gramps_id, - "class_func": Family, - "cursor_func": self.get_family_cursor, - "handles_func": self.get_family_handles, - }) - self._tables['Source'].update( - { - "handle_func": self.get_source_from_handle, - "gramps_id_func": self.get_source_from_gramps_id, - "class_func": Source, - "cursor_func": self.get_source_cursor, - "handles_func": self.get_source_handles, - }) - self._tables['Citation'].update( - { - "handle_func": self.get_citation_from_handle, - "gramps_id_func": self.get_citation_from_gramps_id, - "class_func": Citation, - "cursor_func": self.get_citation_cursor, - "handles_func": self.get_citation_handles, - }) - self._tables['Event'].update( - { - "handle_func": self.get_event_from_handle, - "gramps_id_func": self.get_event_from_gramps_id, - "class_func": Event, - "cursor_func": self.get_event_cursor, - "handles_func": self.get_event_handles, - }) - self._tables['Media'].update( - { - "handle_func": self.get_object_from_handle, - "gramps_id_func": self.get_object_from_gramps_id, - "class_func": MediaObject, - "cursor_func": self.get_media_cursor, - "handles_func": self.get_media_object_handles, - }) - self._tables['Place'].update( - { - "handle_func": self.get_place_from_handle, - "gramps_id_func": self.get_place_from_gramps_id, - "class_func": Place, - "cursor_func": self.get_place_cursor, - "handles_func": self.get_place_handles, - }) - self._tables['Repository'].update( - { - "handle_func": self.get_repository_from_handle, - "gramps_id_func": self.get_repository_from_gramps_id, - "class_func": Repository, - "cursor_func": self.get_repository_cursor, - "handles_func": self.get_repository_handles, - }) - self._tables['Note'].update( - { - "handle_func": self.get_note_from_handle, - "gramps_id_func": self.get_note_from_gramps_id, - "class_func": Note, - "cursor_func": self.get_note_cursor, - "handles_func": self.get_note_handles, - }) - self._tables['Tag'].update( - { - "handle_func": self.get_tag_from_handle, - "gramps_id_func": None, - "class_func": Tag, - "cursor_func": self.get_tag_cursor, - "handles_func": self.get_tag_handles, - }) def get_person_from_handle(self, handle): """ diff --git a/gramps/gen/proxy/referencedbyselection.py b/gramps/gen/proxy/referencedbyselection.py index 50b4d4f03..ae93e83c1 100644 --- a/gramps/gen/proxy/referencedbyselection.py +++ b/gramps/gen/proxy/referencedbyselection.py @@ -82,87 +82,6 @@ class ReferencedBySelectionProxyDb(ProxyDbBase): while len(self.queue): obj_type, handle, reference = self.queue.pop() self.process_object(obj_type, handle, reference) - # need to update _tables with these functions - self._tables['Person'].update( - { - "handle_func": self.get_person_from_handle, - "gramps_id_func": self.get_person_from_gramps_id, - "class_func": Person, - "cursor_func": self.get_person_cursor, - "handles_func": self.get_person_handles, - }) - self._tables['Family'].update( - { - "handle_func": self.get_family_from_handle, - "gramps_id_func": self.get_family_from_gramps_id, - "class_func": Family, - "cursor_func": self.get_family_cursor, - "handles_func": self.get_family_handles, - }) - self._tables['Source'].update( - { - "handle_func": self.get_source_from_handle, - "gramps_id_func": self.get_source_from_gramps_id, - "class_func": Source, - "cursor_func": self.get_source_cursor, - "handles_func": self.get_source_handles, - }) - self._tables['Citation'].update( - { - "handle_func": self.get_citation_from_handle, - "gramps_id_func": self.get_citation_from_gramps_id, - "class_func": Citation, - "cursor_func": self.get_citation_cursor, - "handles_func": self.get_citation_handles, - }) - self._tables['Event'].update( - { - "handle_func": self.get_event_from_handle, - "gramps_id_func": self.get_event_from_gramps_id, - "class_func": Event, - "cursor_func": self.get_event_cursor, - "handles_func": self.get_event_handles, - }) - self._tables['Media'].update( - { - "handle_func": self.get_object_from_handle, - "gramps_id_func": self.get_object_from_gramps_id, - "class_func": MediaObject, - "cursor_func": self.get_media_cursor, - "handles_func": self.get_media_object_handles, - }) - self._tables['Place'].update( - { - "handle_func": self.get_place_from_handle, - "gramps_id_func": self.get_place_from_gramps_id, - "class_func": Place, - "cursor_func": self.get_place_cursor, - "handles_func": self.get_place_handles, - }) - self._tables['Repository'].update( - { - "handle_func": self.get_repository_from_handle, - "gramps_id_func": self.get_repository_from_gramps_id, - "class_func": Repository, - "cursor_func": self.get_repository_cursor, - "handles_func": self.get_repository_handles, - }) - self._tables['Note'].update( - { - "handle_func": self.get_note_from_handle, - "gramps_id_func": self.get_note_from_gramps_id, - "class_func": Note, - "cursor_func": self.get_note_cursor, - "handles_func": self.get_note_handles, - }) - self._tables['Tag'].update( - { - "handle_func": self.get_tag_from_handle, - "gramps_id_func": None, - "class_func": Tag, - "cursor_func": self.get_tag_cursor, - "handles_func": self.get_tag_handles, - }) def queue_object(self, obj_type, handle, reference=True): self.queue.append((obj_type, handle, reference)) diff --git a/gramps/plugins/quickview/filterbyname.py b/gramps/plugins/quickview/filterbyname.py index f12dab592..1fa4c4016 100644 --- a/gramps/plugins/quickview/filterbyname.py +++ b/gramps/plugins/quickview/filterbyname.py @@ -87,30 +87,56 @@ def run(database, document, filter_name, *args, **kwargs): sdoc.paragraph(_("Right-click row (or press ENTER) to see selected items.")) sdoc.paragraph("") stab.columns(_("Object"), _("Count/Total")) - stab.row([_("People"), "Filter", "Person"], - "%d/%d" % (len(database.get_person_handles()), - len(database.basedb.get_person_handles()))) - stab.row([_("Families"), "Filter", "Family"], - "%d/%d" % (len(database.get_family_handles()), - len(database.basedb.get_family_handles()))) - stab.row([_("Events"), "Filter", "Event"], - "%d/%d" % (len(database.get_event_handles()), - len(database.basedb.get_event_handles()))) - stab.row([_("Places"), "Filter", "Place"], - "%d/%d" % (len(database.get_place_handles()), - len(database.basedb.get_place_handles()))) - stab.row([_("Sources"), "Filter", "Source"], - "%d/%d" % (len(database.get_source_handles()), - len(database.basedb.get_source_handles()))) - stab.row([_("Repositories"), "Filter", "Repository"], - "%d/%d" % (len(database.get_repository_handles()), - len(database.basedb.get_repository_handles()))) - stab.row([_("Media"), "Filter", "MediaObject"], - "%d/%d" % (len(database.get_media_object_handles()), - len(database.basedb.get_media_object_handles()))) - stab.row([_("Notes"), "Filter", "Note"], - "%d/%d" % (len(database.get_note_handles()), - len(database.basedb.get_note_handles()))) + if hasattr(database, "db"): + stab.row([_("People"), "Filter", "Person"], + "%d/%d" % (len(database.get_person_handles()), + len(database.db.get_person_handles()))) + stab.row([_("Families"), "Filter", "Family"], + "%d/%d" % (len(database.get_family_handles()), + len(database.db.get_family_handles()))) + stab.row([_("Events"), "Filter", "Event"], + "%d/%d" % (len(database.get_event_handles()), + len(database.db.get_event_handles()))) + stab.row([_("Places"), "Filter", "Place"], + "%d/%d" % (len(database.get_place_handles()), + len(database.db.get_place_handles()))) + stab.row([_("Sources"), "Filter", "Source"], + "%d/%d" % (len(database.get_source_handles()), + len(database.db.get_source_handles()))) + stab.row([_("Repositories"), "Filter", "Repository"], + "%d/%d" % (len(database.get_repository_handles()), + len(database.db.get_repository_handles()))) + stab.row([_("Media"), "Filter", "MediaObject"], + "%d/%d" % (len(database.get_media_object_handles()), + len(database.db.get_media_object_handles()))) + stab.row([_("Notes"), "Filter", "Note"], + "%d/%d" % (len(database.get_note_handles()), + len(database.db.get_note_handles()))) + else: + stab.row([_("People"), "Filter", "Person"], + "%d/%d" % (len(database.get_person_handles()), + len(database.basedb.get_person_handles()))) + stab.row([_("Families"), "Filter", "Family"], + "%d/%d" % (len(database.get_family_handles()), + len(database.basedb.get_family_handles()))) + stab.row([_("Events"), "Filter", "Event"], + "%d/%d" % (len(database.get_event_handles()), + len(database.basedb.get_event_handles()))) + stab.row([_("Places"), "Filter", "Place"], + "%d/%d" % (len(database.get_place_handles()), + len(database.basedb.get_place_handles()))) + stab.row([_("Sources"), "Filter", "Source"], + "%d/%d" % (len(database.get_source_handles()), + len(database.basedb.get_source_handles()))) + stab.row([_("Repositories"), "Filter", "Repository"], + "%d/%d" % (len(database.get_repository_handles()), + len(database.basedb.get_repository_handles()))) + stab.row([_("Media"), "Filter", "MediaObject"], + "%d/%d" % (len(database.get_media_object_handles()), + len(database.basedb.get_media_object_handles()))) + stab.row([_("Notes"), "Filter", "Note"], + "%d/%d" % (len(database.get_note_handles()), + len(database.basedb.get_note_handles()))) sdoc.paragraph("") stab.write(sdoc) return