8634: DB-API Database backend doesn't compute inverse filters correctly

This commit is contained in:
Doug Blank 2015-06-14 09:56:58 -04:00
parent 8b4c5c4ebe
commit 4c47a396a8
4 changed files with 50 additions and 266 deletions

View File

@ -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):
"""

View File

@ -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):
"""

View File

@ -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))

View File

@ -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