[Zope] a newbie in trouble with tree tag and sql methods

Graham Chiu anon_emouse@hotmail.com
Thu, 8 Jul 1999 22:04:35 +1200


In article <LQp7BCADGKg3EwFV@compkarori.co.nz>, Graham Chiu <anon_emouse@hotmail.com>
writes
>Unfortunately I can infinitely expand the tree whereas I want to stop it at one
>expansion.

Well, I've solved my problem ( with some help from Tone ) by using another variable to
produce an empty query which stops the tree from expanding.

Here's the working code though I wonder whether I can optimise it a bit more.

Zsqlmethod:sqlTestTree param:string flag:int

<!--#if "param==''"-->
select distinct userid as obj_id, '' as path, '' as qstring, 
'' as description, 0 as flag  from url order by userid
<!--#else-->
  <!--#if "flag==0"-->
select userid as obj_id, path, qstring, description, 1 as flag
from url where
<!--#sqltest param column=userid type=nb-->
  <!--#else-->
select * from url where userid=''
  <!--#/if-->
<!--#/if-->


The line "select * from url where userid=''" should always return an empty set for this to
work.

and the dtml...

<!--#with "_.namespace(obj_id='', flag=0)"-->
  <!--#tree id=obj_id branches_expr="sqlTestTree(param=obj_id, flag=flag)" single=0-->
    <!--#if "path==''"-->
      <!--#var obj_id-->
    <!--#else-->
       <a href=<!--#var path-->?<!--#var qstring-->><!--#var description--></a><br>
    <!--#/if-->
  <!--#/tree-->
<!--#/with-->

-------
Regards,        Graham Chiu
gchiu<at>compkarori.co.nz