Aha. I've got it now. Change the tree tag to read: <!--#tree id=publication branches_expr="Data.pb_sql(pb = publication)"--> I reproduced your setup with a query of my own (totally different format), and got the same problem as you. That is, the first level showed but the plus signs wouldn't expand anything. The problem isn't with the queries; it's that the tree tag needs a persistent ID value to keep track of what branches are open/closed. By default it uses the object's persistent ID, if it has one, otherwise it uses the Python 'id()' value. However, if the object is the result of an SQL query, there's no persistent ID, and the Python id() will change from hit to hit. So when using query results, it's necessary to do an 'id=primary_key_field_name' in your tree tag to ensure it'll actually work as a tree. I was doing this in all my current production code, but I overlooked it when describing to you what I did. By the way, as you have your query constructed, it will cause the tree to infinitely recurse once you hit the second level. It would be good to restructure it a bit, as follows: <!--#if "pb == ''"--> select distinct publication, count(publication) as pub_cnt from articles where publication != '' group by publication order by publication <!--#else--> select title, 'nosuchpublication' as publication from articles where publication = <!--#sqlvar pb type=string--> <!--#/if--> Without this change, the tree tag will not realize the articles are leaves, because when it calls the query to check on them, it will return all the publications again. At 12:39 AM 6/28/99 +0200, Alexander Staubo wrote:
Here you go:
<!--#with "_.namespace(publication = '')"--> <!--#tree branches_expr="Data.pb_sql(pb = publication)"-->
<!--#var publication--> <!--#/tree--> <!--#/with-->