a newbie in trouble with tree tag and sql methods
hi, i'm trying the tree tag + sql meth example that was discussed in this group some weeks ago. the sql method works fine, tree tag shows the correct information, but the only thing wrong is that expand/collapse of tree doesnt work correctly: the first node expands all other nodes exept itself and all other nodes collapse all nodes. any ideas what might be wrong?? i'm using Zope 2.0.0a3 with python1.52 on linux2.2 and postgresql6.5 the sql method i'm using is: --- name: query argument: param --- SELECT id as obj_id, nimi as name FROM asutus WHERE <!--#if param--> ylem=<!--#sqlvar param type=int--> <!--#else--> ylem IS NULL <!--#/if--> and tree tag is: <!--#with "_.namespace(obj_id=0)"--> <!--#tree branches_expr="query(param=obj_id)" single=0--> <!--#var name-->,<!--#var obj_id--> <!--#/tree--> <!--#/with--> data im'm using is: test=> select id,nimi as name, ylem as paernt_id from asutus; id|name |paernt_id --+-----+--------- 1|tty | 2|ut | 3|ebs | 4|cyber| 1 7|phys | 1 8|chem | 2 6|filo | 2 5|keel | 2 9|tpu | 10|kala | 9 11|kamm | 9 12|jura | 9 (12 rows) Thanks in advance, Lauri
At 07:52 PM 7/4/99 +0300, Lauri Posti wrote:
and tree tag is: <!--#with "_.namespace(obj_id=0)"--> <!--#tree branches_expr="query(param=obj_id)" single=0--> <!--#var name-->,<!--#var obj_id--> <!--#/tree--> <!--#/with-->
Change to: <!--#tree id=obj_id branches_expr="query(param=obj_id)" single=0--> And you should be fine. The problem is that without the id= setting, Zope doesn't know how to tell one object from another when expanding/contracting branches.
In article <199907042001.NAA20866@zope.codeit.com>, Phillip J. Eby <pje@telecommunity.com> writes
At 07:52 PM 7/4/99 +0300, Lauri Posti wrote:
and tree tag is: <!--#with "_.namespace(obj_id=0)"--> <!--#tree branches_expr="query(param=obj_id)" single=0--> <!--#var name-->,<!--#var obj_id--> <!--#/tree--> <!--#/with-->
Change to: <!--#tree id=obj_id branches_expr="query(param=obj_id)" single=0-->
And you should be fine. The problem is that without the id= setting, Zope doesn't know how to tell one object from another when expanding/contracting branches.
Well, encouraged by this, I've also attempted to use the tree tag/sql combination. My table URL stores urls with userid, path, query string, and description of the url. My sql query name: sqlTestTree argument: param <!--#if "param==''"--> select distinct userid as obj_id, '' as path, '' as qstring, '' as description from url order by userid <!--#else--> select userid as obj_id, path, qstring, description from url where <!--#sqltest param column=userid type=nb--> <!--#/if--> My dtml document is as follows: <!--#with "_.namespace(obj_id='')"--> <!--#tree id=obj_id branches_expr="sqlTestTree(param=obj_id)" single=0--> <!--#if "path==''"--> <!--#var obj_id--> <!--#else--> <a href=<!--#var path-->?<!--#var qstring-->><!--#var description--></a><br> <!--#/if--> <!--#/tree--> <!--#/with--> Unfortunately I can infinitely expand the tree whereas I want to stop it at one expansion. ------- Regards, Graham Chiu gchiu<at>compkarori.co.nz
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
participants (3)
-
Graham Chiu -
Lauri Posti -
Phillip J. Eby