7482: Fix python3 problems with new place structure
Based on patches by Marc Hulsman.
This commit is contained in:
parent
8dd6d92184
commit
c364bcd7ad
@ -215,10 +215,12 @@ class DbBsddbTreeCursor(BsddbBaseCursor):
|
||||
"""
|
||||
Iterator
|
||||
"""
|
||||
to_do = ['']
|
||||
_n = self.next_dup
|
||||
to_do = [b'']
|
||||
while to_do:
|
||||
data = self.set(str(to_do.pop()))
|
||||
_n = self.next_dup
|
||||
key = to_do.pop()
|
||||
key = key.encode('utf-8') if not isinstance(key, bytes) else key
|
||||
data = self.set(key)
|
||||
while data:
|
||||
payload = pickle.loads(data[1])
|
||||
yield (payload[0], payload)
|
||||
|
@ -38,7 +38,7 @@ LOG = logging.getLogger(".citation")
|
||||
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import cuni, UNITYPE
|
||||
from ..constfunc import cuni, UNITYPE, handle2internal
|
||||
|
||||
"""
|
||||
methods to upgrade a database from version 13 to current version
|
||||
@ -138,7 +138,7 @@ def gramps_upgrade_17(self):
|
||||
|
||||
if parent_handle is not None:
|
||||
placeref = PlaceRef()
|
||||
placeref.ref = parent_handle
|
||||
placeref.ref = handle2internal(parent_handle)
|
||||
placeref_list = [placeref.serialize()]
|
||||
else:
|
||||
placeref_list = []
|
||||
@ -274,7 +274,7 @@ def add_place(self, name, level, parent, title):
|
||||
place.set_type(PlaceType(7-level))
|
||||
if parent is not None:
|
||||
placeref = PlaceRef()
|
||||
placeref.ref = parent
|
||||
placeref.ref = handle2internal(parent)
|
||||
place.set_placeref_list([placeref])
|
||||
with BSDDBTxn(self.env, self.place_map) as txn:
|
||||
if isinstance(handle, UNITYPE):
|
||||
|
@ -1096,7 +1096,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
"""
|
||||
Find all child places having the given place as the primary parent.
|
||||
"""
|
||||
handle = str(handle)
|
||||
if isinstance(handle, UNITYPE):
|
||||
handle = handle.encode('utf-8')
|
||||
parent_cur = self.get_place_parent_cursor()
|
||||
|
||||
try:
|
||||
|
@ -61,7 +61,7 @@ class RefBase(object):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
self.ref = str(data)
|
||||
self.ref = data
|
||||
return self
|
||||
|
||||
def get_referenced_handles(self):
|
||||
|
@ -30,6 +30,7 @@ Helper class for importing places.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.lib import Place, PlaceType, PlaceRef
|
||||
from gramps.gen.constfunc import handle2internal
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -89,7 +90,7 @@ class PlaceImport(object):
|
||||
if parent:
|
||||
place = self.db.get_place_from_handle(handle)
|
||||
placeref = PlaceRef()
|
||||
placeref.ref = parent
|
||||
placeref.ref = handle2internal(parent)
|
||||
place.set_placeref_list([placeref])
|
||||
self.db.commit_place(place, trans, place.get_change_time())
|
||||
|
||||
@ -103,7 +104,7 @@ class PlaceImport(object):
|
||||
place.place_type = PlaceType(7-type_num)
|
||||
if parent is not None:
|
||||
placeref = PlaceRef()
|
||||
placeref.ref = parent
|
||||
placeref.ref = handle2internal(parent)
|
||||
place.set_placeref_list([placeref])
|
||||
handle = self.db.add_place(place, trans)
|
||||
self.db.commit_place(place, trans)
|
||||
|
Loading…
Reference in New Issue
Block a user