Re: dtml-Variablen in <dtml-in> loops?
Hi Tino, the problem I see with your (I agree: much cleaner) code is that for each group you issue a SQL statement. So if I have 1000 groups you'll end up with 1000 SQL queries. In my (ugly :-) code you'd only have 2 sql queries: - the first one: sqlCount (see previous post) - the second (cached) one outside the iterations: DATA=sqlListProjects (large list with 1000*Projects rows). About the caching: I read that in Dieter's Zope Book: http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html So my question remains: is there either DATA[1:a+b] (both a and b are dtml-Variables) possible or <dtml-in .. start=a+b..> (both a and b are dtml-Variables). Thanks again, Philipp -----Ursprüngliche Nachricht----- Von: Tino Wildenhain Gesendet: So 27.5.2001 17:38 An: Philipp Robbel Cc: zope@zope.org Betreff: Re: dtml-Variablen in <dtml-in> loops? First of all, you dont have to cache SQL results via dtml-let. Zope does this already for you. If you have 2 queries: sqlGroupList: SELECT DISTINCT GroupID FROM Projects and the other: sqlProjectList(arg_GroupID) SELECT ProjectID, Project FROM Projects WHERE GroupID=<dtml-arg_GroupID type=int> so you can: <dtml-in sqlGroupList> GroupID &dtml-GroupID;: <dtml-in "sqlProjectList(arg_GroupID=GroupID)"> <dtml-unless sequence-start>,</dtml-unless> <dtml-var Project> </dtml-in> </dtml-in> This looks a bit cleaner imho ;) Regards Tino Wildenhain
Hi Philipp, --On Sonntag, 27. Mai 2001 23:20 +0200 Philipp Robbel <philipp.robbel@eml.villa-bosch.de> wrote:
Hi Tino,
the problem I see with your (I agree: much cleaner) code is that for each group you issue a SQL statement. So if I have 1000 groups you'll end up with 1000 SQL queries.
you will hardly show 1000 Records at once ;)
In my (ugly :-) code you'd only have 2 sql queries: - the first one: sqlCount (see previous post) - the second (cached) one outside the iterations: DATA=sqlListProjects (large list with 1000*Projects rows).
About the caching: I read that in Dieter's Zope Book: http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
Hm. So Dieter must be wrong since it is documented otherwise. Even more, all database interactions are enclosed in a transaction of the publishing process (if the database adaptor supports this - and its supposed to do that)
So my question remains: is there either DATA[1:a+b] (both a and b are dtml-Variables) possible or <dtml-in .. start=a+b..> (both a and b are dtml-Variables).
how about <dtml-in DATA start=GroupStart size=GroupCount orphan=0> </dtml-in> ? Another solution would be: sqlProjectList: SELECT GroupID,ProjectID,Project FROM Project ORDER BY GroupID,ProjectID <dtml-call "REQUEST.set('marker',-1)"> <dtml-in sqlProjectList> <dtml-if "marker!=GroupID"><dtml-call "REQUEST.set('marker',GroupID)"> Group <dtml-var GroupID>: </dtml-if> <dtml-var Project> </dtml-in> Regards Tino
Thanks again, Philipp
-----Ursprüngliche Nachricht----- Von: Tino Wildenhain Gesendet: So 27.5.2001 17:38 An: Philipp Robbel Cc: zope@zope.org Betreff: Re: dtml-Variablen in <dtml-in> loops?
First of all, you dont have to cache SQL results via dtml-let. Zope does this already for you.
If you have 2 queries: sqlGroupList: SELECT DISTINCT GroupID FROM Projects
and the other: sqlProjectList(arg_GroupID) SELECT ProjectID, Project FROM Projects WHERE GroupID=<dtml-arg_GroupID type=int>
so you can:
<dtml-in sqlGroupList> GroupID &dtml-GroupID;: <dtml-in "sqlProjectList(arg_GroupID=GroupID)"> <dtml-unless sequence-start>,</dtml-unless> <dtml-var Project> </dtml-in> </dtml-in>
This looks a bit cleaner imho ;)
Regards Tino Wildenhain
participants (2)
-
Philipp Robbel -
Tino Wildenhain