Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Do not fail if original state is not found for removed object
Browse files Browse the repository at this point in the history
This is similar of what we do with mofified objects in this case.
  • Loading branch information
kedder committed Aug 13, 2014
1 parent 697450a commit 2b66337
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/mongopersist/datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,14 @@ def abort(self, transaction):
coll.remove({'_id': obj._p_oid.id})
# 2. Re-insert any removed objects.
for obj in self._removed_objects.values():
coll = self.get_collection_from_object(obj)
coll.insert(self._original_states[obj._p_oid])
del self._original_states[obj._p_oid]
db_ref = obj._p_oid
if db_ref in self._original_states:
coll = self.get_collection_from_object(obj)
coll.insert(self._original_states[db_ref])
del self._original_states[db_ref]
else:
LOG.warn('Original state not found while aborting: '
'%r (removed) (%s)', obj, db_ref.id if db_ref else '')
# 3. Reset any changed states.
for obj in self._modified_objects.values():
db_ref = obj._p_oid
Expand Down

0 comments on commit 2b66337

Please sign in to comment.