[Zope] how to accumulate data using ZPT

2005-05-20 Thread prabuddha ray
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 )


Re: [Zope] how to accumulate data using ZPT

2005-05-20 Thread Hugo Ramos
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 [EMAIL PROTECTED] 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 - [EMAIL PROTECTED]
___
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 )


Re: [Zope] how to accumulate data using ZPT

2005-05-20 Thread Tino Wildenhain
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED]

___
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 )


Re: [Zope] how to accumulate data using ZPT

2005-05-20 Thread Hugo Ramos
On 5/20/05, Tino Wildenhain [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED]
 
 


-- 
Hugo Ramos - [EMAIL PROTECTED]
___
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 )


Re: [Zope] how to accumulate data using ZPT

2005-05-20 Thread Tino Wildenhain
Am Freitag, den 20.05.2005, 10:36 +0100 schrieb Hugo Ramos:
 On 5/20/05, Tino Wildenhain [EMAIL PROTECTED] 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 ;)



___
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 )