7582: [Python2] Cannot remove a person having an event reference

This commit is contained in:
Josip 2014-04-06 18:26:42 +02:00
parent a07f411548
commit d702129296
2 changed files with 10 additions and 10 deletions

View File

@ -410,10 +410,8 @@ class DbUndoBSDDB(DbUndo):
"""
Open the undo/redo database
"""
path = (self.path.encode(sys.getfilesystemencoding())
if (isinstance(self.path, UNITYPE) and win()
and sys.version_info[0] < 3)
else self.path)
path = self.path
self.undodb.open(path, db.DB_RECNO, db.DB_CREATE)
def close(self):

View File

@ -307,7 +307,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
dbmap = db.DB(self.env)
dbmap.set_flags(flags)
fname = _encode(os.path.join(file_name, table_name + DBEXT))
fname = os.path.join(file_name, table_name + DBEXT)
if self.readonly:
dbmap.open(fname, table_name, dbtype, DBFLAGS_R)
@ -318,7 +318,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
def __open_shelf(self, file_name, table_name, dbtype=db.DB_HASH):
dbmap = dbshelve.DBShelf(self.env)
fname = _encode(os.path.join(file_name, table_name + DBEXT))
fname = os.path.join(file_name, table_name + DBEXT)
if self.readonly:
dbmap.open(fname, table_name, dbtype, DBFLAGS_R)
@ -641,7 +641,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
env_name = name
try:
self.env.open(_encode(env_name), env_flags)
self.env.open(env_name, env_flags)
except Exception as msg:
_LOG.warning("Error opening db environment: " + str(msg))
try:
@ -1131,14 +1131,16 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
raise DbError(_('An attempt is made to safe a reference key '
'which is partly bytecode, this is not allowed.\n'
'Key is %s') % str(key))
key = str(key)
if sys.version_info[0] >= 3:
key= str(tuple(k for k in key))
else:
key = str(tuple(k.decode('utf-8') for k in key))
if isinstance(key, UNITYPE):
key = key.encode('utf-8')
if not self.readonly:
if not transaction.batch:
old_data = self.reference_map.get(key, txn=txn)
transaction.add(REFERENCE_KEY, TXNDEL, key, old_data, None)
#transaction.reference_del.append(str(key))
self.reference_map.delete(key, txn=txn)
def __add_reference(self, key, data, transaction, txn):
@ -2217,7 +2219,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
# Environment name is now based on the filename
env_name = name
self.env.open(_encode(env_name), env_flags)
self.env.open(env_name, env_flags)
self.env.txn_checkpoint()
self.metadata = self.__open_shelf(full_name, META)