From 162d26d4dc1de841358ae2c49ff88d4cba631cf1 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 25 Mar 2016 09:22:58 -0400 Subject: [PATCH] 9331: Empty handle, bsddb backend and place --- gramps/gen/db/generic.py | 2 +- gramps/gen/lib/struct.py | 8 +++----- gramps/plugins/database/bsddb_support/read.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gramps/gen/db/generic.py b/gramps/gen/db/generic.py index 0cbc42b04..165ed8389 100644 --- a/gramps/gen/db/generic.py +++ b/gramps/gen/db/generic.py @@ -1588,7 +1588,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): >>> self.get_from_name_and_handle("Person", "a7ad62365bc652387008") >>> self.get_from_name_and_handle("Media", "c3434653675bcd736f23") """ - if table_name in self.get_table_func(): + if table_name in self.get_table_func() and handle: return self.get_table_func(table_name,"handle_func")(handle) return None diff --git a/gramps/gen/lib/struct.py b/gramps/gen/lib/struct.py index 13478f583..febad4de8 100644 --- a/gramps/gen/lib/struct.py +++ b/gramps/gen/lib/struct.py @@ -211,15 +211,12 @@ class Struct(object): current = getattr(current, item) return current - def get_media_from_handle(self, handle): - return self.db.get_from_name_and_handle(handle.classname, str(handle)) - def handle_join(self, item): """ If the item is a handle, look up reference object. """ if isinstance(item, HandleClass) and self.db: - obj = self.get_media_from_handle(item) + obj = self.db.get_from_name_and_handle(item.classname, str(item)) if obj: return Struct(obj.to_struct(), self.db) else: @@ -263,7 +260,8 @@ class Struct(object): if struct is None: # invalid part to set, skip return if isinstance(struct, HandleClass): - struct = self.get_media_from_handle(struct).to_struct() + obj = self.db.get_from_name_and_handle(struct.classname, str(struct)) + struct = obj.to_struct() # keep track of primary object for update, below if isinstance(struct, dict) and "_class" in struct and self.primary_object_q(struct["_class"]): primary_obj = struct diff --git a/gramps/plugins/database/bsddb_support/read.py b/gramps/plugins/database/bsddb_support/read.py index 00a4ad90e..ecb8b9c1e 100644 --- a/gramps/plugins/database/bsddb_support/read.py +++ b/gramps/plugins/database/bsddb_support/read.py @@ -716,7 +716,7 @@ class DbBsddbRead(DbReadBase, Callback): >>> self.get_from_name_and_handle("Person", "a7ad62365bc652387008") >>> self.get_from_name_and_handle("Media", "c3434653675bcd736f23") """ - if table_name in self.get_table_func(): + if table_name in self.get_table_func() and handle: return self.get_table_func(table_name,"handle_func")(handle) return None