@@ -62,7 +62,13 @@ class DbMixin:
62
62
"""
63
63
64
64
def __find_primary_from_handle (
65
- self , handle , transaction , class_type , get_raw_obj_data , add_func
65
+ self ,
66
+ handle ,
67
+ transaction ,
68
+ class_type ,
69
+ has_obj_handle ,
70
+ get_raw_obj_data ,
71
+ add_func ,
66
72
):
67
73
"""
68
74
Find a primary object of class_type in the database from the passed
@@ -77,8 +83,8 @@ def __find_primary_from_handle(
77
83
obj = class_type ()
78
84
handle = str (handle )
79
85
new = True
80
- raw = get_raw_obj_data (handle )
81
- if raw is not None :
86
+ if has_obj_handle (handle ):
87
+ raw = get_raw_obj_data ( handle )
82
88
obj = data_to_object (raw )
83
89
# references create object with id None before object is really made
84
90
if obj .gramps_id is not None :
@@ -89,7 +95,13 @@ def __find_primary_from_handle(
89
95
return obj , new
90
96
91
97
def __find_table_from_handle (
92
- self , handle , transaction , class_type , get_raw_obj_data , add_func
98
+ self ,
99
+ handle ,
100
+ transaction ,
101
+ class_type ,
102
+ has_obj_handle ,
103
+ get_raw_obj_data ,
104
+ add_func ,
93
105
):
94
106
"""
95
107
Find a table object of class_type in the database from the passed
@@ -103,8 +115,8 @@ def __find_table_from_handle(
103
115
"""
104
116
obj = class_type ()
105
117
handle = str (handle )
106
- raw = get_raw_obj_data (handle )
107
- if raw is not None :
118
+ if has_obj_handle (handle ):
119
+ raw = get_raw_obj_data ( handle )
108
120
obj = data_to_object (raw )
109
121
return obj , False
110
122
else :
@@ -154,7 +166,12 @@ def find_person_from_handle(self, handle, transaction):
154
166
@rtype: tuple
155
167
"""
156
168
return self .__find_primary_from_handle (
157
- handle , transaction , Person , self .get_raw_person_data , self .add_person
169
+ handle ,
170
+ transaction ,
171
+ Person ,
172
+ self .has_person_handle ,
173
+ self .get_raw_person_data ,
174
+ self .add_person ,
158
175
)
159
176
160
177
def find_source_from_handle (self , handle , transaction ):
@@ -168,7 +185,12 @@ def find_source_from_handle(self, handle, transaction):
168
185
@rtype: tuple
169
186
"""
170
187
return self .__find_primary_from_handle (
171
- handle , transaction , Source , self .get_raw_source_data , self .add_source
188
+ handle ,
189
+ transaction ,
190
+ Source ,
191
+ self .has_source_handle ,
192
+ self .get_raw_source_data ,
193
+ self .add_source ,
172
194
)
173
195
174
196
def find_event_from_handle (self , handle , transaction ):
@@ -182,7 +204,12 @@ def find_event_from_handle(self, handle, transaction):
182
204
@rtype: tuple
183
205
"""
184
206
return self .__find_primary_from_handle (
185
- handle , transaction , Event , self .get_raw_event_data , self .add_event
207
+ handle ,
208
+ transaction ,
209
+ Event ,
210
+ self .has_event_handle ,
211
+ self .get_raw_event_data ,
212
+ self .add_event ,
186
213
)
187
214
188
215
def find_object_from_handle (self , handle , transaction ):
@@ -196,7 +223,12 @@ def find_object_from_handle(self, handle, transaction):
196
223
@rtype: tuple
197
224
"""
198
225
return self .__find_primary_from_handle (
199
- handle , transaction , Media , self .get_raw_object_data , self .add_object
226
+ handle ,
227
+ transaction ,
228
+ Media ,
229
+ self .has_object_handle ,
230
+ self .get_raw_object_data ,
231
+ self .add_object ,
200
232
)
201
233
202
234
def find_place_from_handle (self , handle , transaction ):
@@ -210,7 +242,12 @@ def find_place_from_handle(self, handle, transaction):
210
242
@rtype: tuple
211
243
"""
212
244
return self .__find_primary_from_handle (
213
- handle , transaction , Place , self .get_raw_place_data , self .add_place
245
+ handle ,
246
+ transaction ,
247
+ Place ,
248
+ self .has_place_handle ,
249
+ self .get_raw_place_data ,
250
+ self .add_place ,
214
251
)
215
252
216
253
def find_family_from_handle (self , handle , transaction ):
@@ -224,7 +261,12 @@ def find_family_from_handle(self, handle, transaction):
224
261
@rtype: tuple
225
262
"""
226
263
return self .__find_primary_from_handle (
227
- handle , transaction , Family , self .get_raw_family_data , self .add_family
264
+ handle ,
265
+ transaction ,
266
+ Family ,
267
+ self .has_family_handle ,
268
+ self .get_raw_family_data ,
269
+ self .add_family ,
228
270
)
229
271
230
272
def find_repository_from_handle (self , handle , transaction ):
@@ -241,6 +283,7 @@ def find_repository_from_handle(self, handle, transaction):
241
283
handle ,
242
284
transaction ,
243
285
Repository ,
286
+ self .has_repository_handle ,
244
287
self .get_raw_repository_data ,
245
288
self .add_repository ,
246
289
)
@@ -256,7 +299,12 @@ def find_note_from_handle(self, handle, transaction):
256
299
@rtype: tuple
257
300
"""
258
301
return self .__find_primary_from_handle (
259
- handle , transaction , Note , self .get_raw_note_data , self .add_note
302
+ handle ,
303
+ transaction ,
304
+ Note ,
305
+ self .has_note_handle ,
306
+ self .get_raw_note_data ,
307
+ self .add_note ,
260
308
)
261
309
262
310
def find_tag_from_handle (self , handle , transaction ):
@@ -270,7 +318,12 @@ def find_tag_from_handle(self, handle, transaction):
270
318
@rtype: tuple
271
319
"""
272
320
return self .__find_table_from_handle (
273
- handle , transaction , Tag , self .get_raw_tag_data , self .add_tag
321
+ handle ,
322
+ transaction ,
323
+ Tag ,
324
+ self .has_tag_handle ,
325
+ self .get_raw_tag_data ,
326
+ self .add_tag ,
274
327
)
275
328
276
329
def check_person_from_handle (self , handle , transaction , set_gid = True ):
0 commit comments