Commit 35d06867 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c6785679
......@@ -410,11 +410,11 @@ def Restructure(ztree, newStructure):
# non-empty BTree".
zstate = unset = object()
if len(node.keyv) == 0:
child = node.children[0]
if len(rlevelv) == 2: # only 2 levels
assert len(rlevelv[0]) == 1 # top-one has empty tree
assert rlevelv[0][0].node is node
child = node.children[0] # bottom-on has 1 bucket
assert isinstance(child, Bucket)
assert isinstance(child, Bucket)# bottom-on has 1 bucket
assert len(rlevelv[1]) == 1
assert rlevelv[1][0].node is child
......@@ -422,10 +422,20 @@ def Restructure(ztree, newStructure):
if len(child.keyv) == 0:
zstate = None
# tree with single bucket withou oid -> tree with embedded bucket
# tree with single bucket without oid -> tree with embedded bucket
elif child.Z._p_oid is None:
zstate = ((child.Z.__getstate__(),),)
# more than 2 levels. For .../T/B B._p_oid must be set - else
# T.__getstate__ will embed B instead of preserving what we
# pass into T.__setstate__
else:
if isinstance(child, Bucket) and child.Z._p_oid is None:
if ztree._p_jar is None:
raise ValueError("Cannot generate .../T/B topology not under ZODB connection")
ztree._p_jar.add(child.Z)
assert child.Z._p_oid is not None
if zstate is unset:
# normal tree node
zstate = ()
......
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