fix error from fix encoding issue for python 3

svn: r21070
This commit is contained in:
Benny Malengier 2013-01-11 17:20:16 +00:00
parent 976dd620a2
commit d9c1a330f3
2 changed files with 13 additions and 2 deletions

View File

@ -102,6 +102,17 @@ DBERRS = (db.DBRunRecoveryError, db.DBAccessError,
# 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):
"""
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,
DbTxn, BsddbBaseCursor, BsddbDowngradeError, DbVersionError,
DbEnvironmentError, DbUpgradeRequiredError, find_surname,
find_surname_name, DbUndoBSDDB as DbUndo)
find_byte_surname, find_surname_name, DbUndoBSDDB as DbUndo)
from .dbconst import *
from ..utils.callback import Callback
from ..utils.cast import (conv_unicode_tosrtkey, conv_dbstr_to_unicode)
@ -718,7 +718,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
if not self.readonly:
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.family_map, self.fid_trans, find_idmap),
(self.event_map, self.eid_trans, find_idmap),