I've this report wherein i've to print the column total iin last row. column values are from database. so far I'm a total loss. do i need to have cookies to store this total? plz gimme ideas. -- Share the vision of difference with ME
Yellow, What DBMS are you using??? MySQL??? If so just have a sql method do this: ========== SELECT COUNT( '*' ) AS total FROM yourtable ========== Then call the variable total where you need it! Regards hr On 5/20/05, prabuddha ray <buddharay@gmail.com> wrote:
I've this report wherein i've to print the column total iin last row. column values are from database. so far I'm a total loss. do i need to have cookies to store this total?
plz gimme ideas.
-- Share the vision of difference with ME _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Hugo Ramos - ramosh@gmail.com
Am Freitag, den 20.05.2005, 09:52 +0100 schrieb Hugo Ramos:
Yellow,
What DBMS are you using??? MySQL??? If so just have a sql method do this: ========== SELECT COUNT( '*' ) AS total FROM yourtable ==========
Are you sure about the ' '? looks strange.
Then call the variable total where you need it!
Regards hr
On 5/20/05, prabuddha ray <buddharay@gmail.com> wrote:
I've this report wherein i've to print the column total iin last row. column values are from database. so far I'm a total loss. do i need to have cookies to store this total?
simplest solution if you need the data anyway: a python script where you do the zsql method results=context.whateverZSQLMethod(args...) return context.yourPageTemplate(results=results,count=len(results)) and use tal:content="options/count" in the template where you need count. If its a sum you need, just work over your resultset or use a separate query. Easiest to work over result set (especially if the select is costy) results=context.whateverZSQLMethod(args...) total=0 for item in results: if item.value: # this handles the case of nulls total+=item.value and use the total as argument: return context.yourPageTemplate(results=results, count=len(results), total=total) -- Tino Wildenhain <tino@wildenhain.de>
On 5/20/05, Tino Wildenhain <tino@wildenhain.de> wrote:
Am Freitag, den 20.05.2005, 09:52 +0100 schrieb Hugo Ramos:
Yellow,
What DBMS are you using??? MySQL??? If so just have a sql method do this: ========== SELECT COUNT( '*' ) AS total FROM yourtable ==========
Are you sure about the ' '? looks strange.
It works both ways... With or without the ' ' !
Then call the variable total where you need it!
Regards hr
On 5/20/05, prabuddha ray <buddharay@gmail.com> wrote:
I've this report wherein i've to print the column total iin last row. column values are from database. so far I'm a total loss. do i need to have cookies to store this total?
simplest solution if you need the data anyway: a python script where you do the zsql method
results=context.whateverZSQLMethod(args...)
return context.yourPageTemplate(results=results,count=len(results))
and use
tal:content="options/count" in the template where you need count. If its a sum you need, just work over your resultset or use a separate query.
Easiest to work over result set (especially if the select is costy)
results=context.whateverZSQLMethod(args...)
total=0 for item in results: if item.value: # this handles the case of nulls total+=item.value
and use the total as argument:
return context.yourPageTemplate(results=results, count=len(results), total=total)
-- Tino Wildenhain <tino@wildenhain.de>
-- Hugo Ramos - ramosh@gmail.com
Am Freitag, den 20.05.2005, 10:36 +0100 schrieb Hugo Ramos:
On 5/20/05, Tino Wildenhain <tino@wildenhain.de> wrote:
Am Freitag, den 20.05.2005, 09:52 +0100 schrieb Hugo Ramos:
Yellow,
What DBMS are you using??? MySQL??? If so just have a sql method do this: ========== SELECT COUNT( '*' ) AS total FROM yourtable ==========
Are you sure about the ' '? looks strange.
It works both ways... With or without the ' ' !
well. another reason to avoid mysql I guess ;)
sorry for delay, but the options you gave are ruled out. actually not all the rows in the column have the values. further the total i'm looking for will result in a very complex query that i dont want to do onsidering the no. of rows are high. I just need something like a var in my ZPT which can just sum up the values if they are present. value's prsence i'm checking using tal:condition but how to add the value repeatedly in the sum var. kindly help. On 5/20/05, Tino Wildenhain <tino@wildenhain.de> wrote:
Am Freitag, den 20.05.2005, 10:36 +0100 schrieb Hugo Ramos:
On 5/20/05, Tino Wildenhain <tino@wildenhain.de> wrote:
Am Freitag, den 20.05.2005, 09:52 +0100 schrieb Hugo Ramos:
Yellow,
What DBMS are you using??? MySQL??? If so just have a sql method do this: ========== SELECT COUNT( '*' ) AS total FROM yourtable ==========
Are you sure about the ' '? looks strange.
It works both ways... With or without the ' ' !
well. another reason to avoid mysql I guess ;)
-- Share the vision of difference with ME
Use two things: a page template and a Python script... here's an example: page template body ------------------ <div tal:define="L python: [1,2,3,4]; A python: context.sum_of(L)"> <div tal:repeat="V L" tal:content="V">1</div> <div tal:content="A">total</div> </div> python script "sum_of" body --------------------------- ## Script (Python) "sum_of" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=L ##title= ## x = 0 for val in L: x = x + val return x On Fri, 2005-05-20 at 03:54 -0700, prabuddha ray wrote:
sorry for delay, but the options you gave are ruled out. actually not all the rows in the column have the values. further the total i'm looking for will result in a very complex query that i dont want to do onsidering the no. of rows are high.
I just need something like a var in my ZPT which can just sum up the values if they are present. value's prsence i'm checking using tal:condition but how to add the value repeatedly in the sum var.
kindly help.
On 5/20/05, Tino Wildenhain <tino@wildenhain.de> wrote:
Am Freitag, den 20.05.2005, 10:36 +0100 schrieb Hugo Ramos:
On 5/20/05, Tino Wildenhain <tino@wildenhain.de> wrote:
Am Freitag, den 20.05.2005, 09:52 +0100 schrieb Hugo Ramos:
Yellow,
What DBMS are you using??? MySQL??? If so just have a sql method do this: ========== SELECT COUNT( '*' ) AS total FROM yourtable ==========
Are you sure about the ' '? looks strange.
It works both ways... With or without the ' ' !
well. another reason to avoid mysql I guess ;)
Am Freitag, den 20.05.2005, 03:54 -0700 schrieb prabuddha ray:
sorry for delay, but the options you gave are ruled out. actually not all the rows in the column have the values.
Which is perfectly met by the if statement. Please read _my_ post again and to the end.
further the total i'm looking for will result in a very complex query that i dont want to do onsidering the no. of rows are high.
I just need something like a var in my ZPT which can just sum up the values if they are present. value's prsence i'm checking using tal:condition but how to add the value repeatedly in the sum var.
No, you definitively dont want that type of algorithm implement in ZPT. Thats better done in python scripts. The skeleton again in my mail. Forget about the count() for a moment. Regards Tino -- Tino Wildenhain <tino@wildenhain.de>
participants (4)
-
Chris McDonough -
Hugo Ramos -
prabuddha ray -
Tino Wildenhain