Here you go: <!--#with "_.namespace(publication = '')"--> <!--#tree branches_expr="Data.pb_sql(pb = publication)"--> <!--#var publication--> <!--#/tree--> <!--#/with--> -- Alexander Staubo http://www.mop.no/~alex/ "`This must be Thursday,' said Arthur to himself, sinking low over his beer, `I never could get the hang of Thursdays.'" --Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
-----Original Message----- From: Phillip J. Eby [mailto:pje@telecommunity.com] Sent: 28. juni 1999 00:37 To: Alexander Staubo; Zope Mailing List (E-mail) Subject: RE: [Zope] Tree tag and SQL methods?
Can you post the source of your tree tag call as well? Thanks.
At 07:21 PM 6/27/99 +0200, Alexander Staubo wrote:
No offense taken -- yes, of course I have tested it. :-)
I have not tested using the #tree tag with the second output though, but that would meaningless (the second output should be rendered as leaf nodes). I even tried having the second query output _all_ data in the table, to no avail. Here's my query:
<!--#if "pb == ''"--> select distinct publication, count(publication) as pub_cnt from articles where publication != '' group by publication order by publication <!--#else--> select title from articles where publication = <!--#sqlvar pb type=string--> <!--#/if-->
Here, pb is the publication argument. I assure you, the second part of the query does execute correctly.
-- Alexander Staubo http://www.mop.no/~alex/ "`This must be Thursday,' said Arthur to himself, sinking low over his beer, `I never could get the hang of Thursdays.'" --Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
-----Original Message----- From: Phillip J. Eby [mailto:pje@telecommunity.com] Sent: 27. juni 1999 18:07 To: Alexander Staubo; Zope Mailing List (E-mail) Subject: RE: [Zope] Tree tag and SQL methods?
Don't be offended by this suggestion, but, have you tried having the tree print out all the variables that would affect the 'second' query, and then plugging them into manage_test of the query? My guess is you'll find that there's something you've overlooked as far as how output of the first query gets fed into the second, or else the second is just plain wrong.
At 03:36 PM 6/26/99 +0200, Alexander Staubo wrote:
Doesn't improve anything: While the "second" part of the query -- the one that's supposed to collect the leaf articles -- clearly executes, no data is displayed. Only the first level -- the publications list -- is rendered, with "plus" icons. Clicking on the icon runs the query but no data is there.
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(For developer-specific issues, use the companion list, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
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-->
participants (2)
-
Alexander Staubo -
Phillip J. Eby