[Zope] Help: Recursive querying
Tom Schwaller
Tom.Schwaller@linux-magazin.de
Sun, 08 Aug 1999 18:46:18 -0100
Rob Page wrote:
> Try:
>
> SQL Method sqlSelectChildren:
> ---
> select * from posts
> where
> <!--#if "parent_id == 0"-->
> parent_id is NULL
> <!--#else-->
> parent_id = <!--#sqlvar parent_id type=int-->
> <!--#/if-->
> ---
>
> Now the tree. This DTML gives a tree, with each node in the tree a
> link to URL1/main_view?obj_id=<the object's id>
>
> ---
> <!--#with "_.namespace(parent_id = 0)"-->
> <!--#tree id=parent_id
> branches_expr="sqlSelectChildren(parent_id=parent_id)"-->
> <a href="<!--#var URL1-->/ViewPost?parent_id=<!--#var
> parent_id-->">
> <!--#var title-->
> </a>
> <!--#/tree-->
> <!--#/with-->
Lat week I did an example to test recursive calls
with nearly the same TABLE-design
(parent_id=father was the main difference + other entries in the
table..)). To see the whole hierarchy I put
<!--#var rekursiv-->
in a file and "rekursiv" was somehting like..
<!--#in "getChildren(root=root)"-->
<LI>..........</LI>
<!--#with "_.namespace(root=child)"-->
<!--#var rekursiv-->
<!--#/with-->
<!--#/in-->
I was trying to figure out the code obove,
so I was very happy to see how to do it.
Unfortunately it does not work.
When I test it I see nothing.
I tried to take a look at a subtree with
<!--#with "_.namespace(parent_id = 4)"-->
...
and got something, but not what you would expect.
The tree reproduces itself in an endless way!
sqlSelectChildren works fine (when I plug in
a parent_id, I see the children as expected..),
so the problem is located in the other part. The code
looks correct, so I do not have a clue what could be wrong??
Has anybody got this example running?
--
Tom