fix bug on database errors; remove bsddb transaction for batch operations

svn: r13283
This commit is contained in:
Gerald Britton 2009-10-01 20:38:23 +00:00
parent f896b55e3e
commit f186d8bce8

View File

@ -212,9 +212,9 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback):
exception is raised. exception is raised.
""" """
@wraps(func) @wraps(func)
def try_(*args, **kwargs): def try_(self, *args, **kwargs):
try: try:
return func(*args, **kwargs) return func(self, *args, **kwargs)
except DBERRS, msg: except DBERRS, msg:
self.__log_error() self.__log_error()
raise Errors.DbError(msg) raise Errors.DbError(msg)
@ -1357,16 +1357,15 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback):
obj.change = int(change_time if change_time else time.time()) obj.change = int(change_time if change_time else time.time())
handle = str(obj.handle) handle = str(obj.handle)
self.update_reference_map(obj, transaction)
# If this is a batch operation, just write the data # If this is a batch operation, just write the data
if transaction.batch: if transaction.batch:
with BSDDBTxn(self.env, data_map) as txn: data_map.put(handle, obj.serialize())
self.update_reference_map(obj, transaction, txn=txn.txn)
txn.put(handle, obj.serialize())
old_data = None old_data = None
# Otherwise, this is a non-batch operation, so queue the transaction # Otherwise, this is a non-batch operation, so queue the transaction
else: else:
self.update_reference_map(obj, transaction)
old_data = data_map.get(handle, txn=self.txn) old_data = data_map.get(handle, txn=self.txn)
new_data = obj.serialize() new_data = obj.serialize()
op = TXNUPD if old_data else TXNADD op = TXNUPD if old_data else TXNADD