Commit 9b45ccc9 authored by Vincent Pelletier's avatar Vincent Pelletier

Check removed value is the expected one in __update and __updateSet.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2052 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 576bea44
...@@ -296,6 +296,9 @@ class NodeManager(object): ...@@ -296,6 +296,9 @@ class NodeManager(object):
def __update(self, index_dict, old_key, new_key, node): def __update(self, index_dict, old_key, new_key, node):
""" Update an index from old to new key """ """ Update an index from old to new key """
if old_key is not None: if old_key is not None:
assert index_dict[old_key] is node, '%r is stored as %s, ' \
'moving %r to %s' % (index_dict[old_key], old_key, node,
new_key)
del index_dict[old_key] del index_dict[old_key]
if new_key is not None: if new_key is not None:
index_dict[new_key] = node index_dict[new_key] = node
...@@ -322,7 +325,7 @@ class NodeManager(object): ...@@ -322,7 +325,7 @@ class NodeManager(object):
def __updateSet(self, set_dict, old_key, new_key, node): def __updateSet(self, set_dict, old_key, new_key, node):
""" Update a set index from old to new key """ """ Update a set index from old to new key """
if old_key in set_dict and node in set_dict[old_key]: if old_key in set_dict:
set_dict[old_key].remove(node) set_dict[old_key].remove(node)
if new_key is not None: if new_key is not None:
set_dict.setdefault(new_key, set()).add(node) set_dict.setdefault(new_key, set()).add(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment