[Zope] Help: Recursive querying

Stephan Richter SRichter@ixl.com
Sun, 8 Aug 1999 12:00:54 -0500


I wrote Rob. I had the same problem. Could not figure it out either.
I think the call
branches_expr="sqlSelectChildren(parent_id=parent_id)"
is wrong and should be:
branches_expr="sqlSelectChildren(parent_id=obj_id)"
					    ********
But obj_id is not defined, therefore it does not work. But I am pretty sure
that's it.
Can anyone help?

stephan

On Sun, 08 Aug 1999, you wrote:
> 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
--
Stephan Richter
iXL - Software Designer and Engineer