diff --git a/gramps/gen/db/generic.py b/gramps/gen/db/generic.py index bfc320a33..e6abf04df 100644 --- a/gramps/gen/db/generic.py +++ b/gramps/gen/db/generic.py @@ -800,20 +800,6 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): return self._get_table_func(table_name) return None - def get_from_name_and_handle(self, table_name, handle): - """ - Returns a gen.lib object (or None) given table_name and - handle. - - Examples: - - >>> self.get_from_name_and_handle("Person", "a7ad62365bc652387008") - >>> self.get_from_name_and_handle("Media", "c3434653675bcd736f23") - """ - if table_name in self._get_table_func() and handle: - return self._get_table_func(table_name, "handle_func")(handle) - return None - def get_from_name_and_gramps_id(self, table_name, gramps_id): """ Returns a gen.lib object (or None) given table_name and diff --git a/gramps/gen/plug/_gramplet.py b/gramps/gen/plug/_gramplet.py index 34a8dfad9..76b097224 100644 --- a/gramps/gen/plug/_gramplet.py +++ b/gramps/gen/plug/_gramplet.py @@ -133,11 +133,12 @@ class Gramplet: def get_active_object(self, nav_type): """ Return the object of the active handle for the given navigation type. - Assumes nav_type is one of the codes of Db.get_by_name. """ handle = self.uistate.get_active(nav_type, self.nav_group) - if nav_type in self.dbstate.db.get_table_names() and handle: - return self.dbstate.db.get_from_name_and_handle(nav_type, handle) + handle_func = getattr(self.dbstate.db, + 'get_%s_from_handle' % nav_type.lower()) + if handle: + return handle_func(handle) return None def set_active(self, nav_type, handle): diff --git a/gramps/plugins/db/bsddb/read.py b/gramps/plugins/db/bsddb/read.py index 9e4beb255..3d222d5d5 100644 --- a/gramps/plugins/db/bsddb/read.py +++ b/gramps/plugins/db/bsddb/read.py @@ -503,20 +503,6 @@ class DbBsddbRead(DbReadBase, Callback): return self._get_table_func(table_name,"gramps_id_func")(gramps_id) return None - def get_from_name_and_handle(self, table_name, handle): - """ - Returns a gen.lib object (or None) given table_name and - handle. - - Examples: - - >>> self.get_from_name_and_handle("Person", "a7ad62365bc652387008") - >>> self.get_from_name_and_handle("Media", "c3434653675bcd736f23") - """ - if table_name in self._get_table_func() and handle: - return self._get_table_func(table_name,"handle_func")(handle) - return None - def set_prefixes(self, person, media, family, source, citation, place, event, repository, note): self.set_person_id_prefix(person)