fix error from fix encoding issue for python 3

svn: r21069
This commit is contained in:
Benny Malengier 2013-01-11 17:20:00 +00:00
parent f4e6ffb4be
commit a4abc9f26a
2 changed files with 13 additions and 2 deletions

View File

@ -102,6 +102,17 @@ DBERRS = (db.DBRunRecoveryError, db.DBAccessError,
# Helper functions # Helper functions
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def find_byte_surname(key, data):
"""
Creating a surname from raw data of a person, to use for sort and index
returns a byte string
"""
surn = __index_surname(data[3][5])
# in python 3 we work with unicode internally, but need byte function sometimes
if isinstance(surn, UNITYPE):
return surn.encode('utf-8')
return surn
def find_surname(key, data): def find_surname(key, data):
""" """
Creating a surname from raw data of a person, to use for sort and index Creating a surname from raw data of a person, to use for sort and index

View File

@ -74,7 +74,7 @@ from ..lib.researcher import Researcher
from . import (DbBsddbRead, DbWriteBase, BSDDBTxn, from . import (DbBsddbRead, DbWriteBase, BSDDBTxn,
DbTxn, BsddbBaseCursor, BsddbDowngradeError, DbVersionError, DbTxn, BsddbBaseCursor, BsddbDowngradeError, DbVersionError,
DbEnvironmentError, DbUpgradeRequiredError, find_surname, DbEnvironmentError, DbUpgradeRequiredError, find_surname,
find_surname_name, DbUndoBSDDB as DbUndo) find_byte_surname, find_surname_name, DbUndoBSDDB as DbUndo)
from .dbconst import * from .dbconst import *
from ..utils.callback import Callback from ..utils.callback import Callback
from ..utils.cast import (conv_unicode_tosrtkey, conv_dbstr_to_unicode) from ..utils.cast import (conv_unicode_tosrtkey, conv_dbstr_to_unicode)
@ -718,7 +718,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if not self.readonly: if not self.readonly:
assoc = [ assoc = [
(self.person_map, self.surnames, find_surname), (self.person_map, self.surnames, find_byte_surname),
(self.person_map, self.id_trans, find_idmap), (self.person_map, self.id_trans, find_idmap),
(self.family_map, self.fid_trans, find_idmap), (self.family_map, self.fid_trans, find_idmap),
(self.event_map, self.eid_trans, find_idmap), (self.event_map, self.eid_trans, find_idmap),