[Zope] recursion in zope.
ghaley@mail.venaca.com
ghaley@mail.venaca.com
Fri, 6 Apr 2001 00:03:09 -0400 (EDT)
hi,
recursion will be the bane of my existence.
i have something like the following data structure:
base_id node_num type par children
in this, base id is a unique id, node num is unique for a user, par is the
node num from which the instance of the node num derives, and children are
the node nums that derive from the node num. the type is either a branch
or a leaf. a branch can have either more branches or leaves, but not both.
(in case it is not obvious, the data structure is building a tree-list).
but i need to be able to traverse the tree outside of the tree-list
structure to solve my problem.
base_id type node_num par children
1010 B 2 1 [3, 5, 10, 25]
1011 B 3 2 [6, 7, 8, 9]
1912 L 5 2 []
1913 L 6 3 []
2011 L 7 3 []
2012 L 8 3 []
2244 L 9 3 []
2250 B 10 2 [11, 12, 13]
2251 B 11 10 []
Rules and coding:
A type of B means a branch, a type of L is a leaf.
A node of a type B cannot contain both nodes of type B and type L, so a B
type with the first element of a B cannot contain subsequent Leaves. And
a B type with the first element of L cannot contain any other B types.
i have written a method that iterates through a list of the children. if
the first child points to a node that is a terminal child (L), it stops
and prints out the identification of the child.
it will also expand out a list of nodes containing terminal children
[ good heavens this sounds grim! ]
but when i try to get it to expand those sub-nodes of type B i get an
error stating excessive recursion; yet, if i look (via view source) at the
error screen, the source shows the expansion down to a single sub-branch,
and no lower; and it never displays the error trace. a strangeness that
has been popping up recently -- i.e., an error, whose source shows what i
expected the method to do, but does not include an error trace.
i would post the relevant code, but it is in two files and rather long.
if anyone has had experience with recursion in zope and can lend some
advice, or point out a how-to, i would very much appreciate it.
many thanks for any pointers.
ciao!
greg.
Gregory Haley
DBA/Web Programmer
Venaca, LLC.