Commit deb66d0f authored by Martijn Pieters's avatar Martijn Pieters

Encode depth of a tree node with '_' characters instead of '.' characters,

as endoded node ids can start with a '.' as well. Also more rigorously test
for an encoded depth when decoding.
parent c277ff7c
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
############################################################################## ##############################################################################
__doc__='''Tree manipulation classes __doc__='''Tree manipulation classes
$Id: Tree.py,v 1.7 2002/10/03 21:08:40 mj Exp $''' $Id: Tree.py,v 1.8 2002/10/03 21:50:17 mj Exp $'''
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
from Acquisition import Explicit from Acquisition import Explicit
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
...@@ -189,7 +189,7 @@ def encodeExpansion(nodes): ...@@ -189,7 +189,7 @@ def encodeExpansion(nodes):
dd = last_depth - node.depth + 1 dd = last_depth - node.depth + 1
last_depth = node.depth last_depth = node.depth
if dd > 0: if dd > 0:
steps.append('.' * dd) steps.append('_' * dd)
steps.append(node.id) steps.append(node.id)
node.expansion_number = n node.expansion_number = n
n = n + 1 n = n + 1
...@@ -207,7 +207,7 @@ def decodeExpansion(s, nth=None): ...@@ -207,7 +207,7 @@ def decodeExpansion(s, nth=None):
if nth is not None: if nth is not None:
nth_pair = (None, None) nth_pair = (None, None)
for step in s.split(':'): for step in s.split(':'):
if step[:1] == '.': if step == len(step) * '_':
pop = len(step) - 1 pop = len(step) - 1
continue continue
if pop < 0: if pop < 0:
......
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