Personal tools
You are here: Home Lists ZPUG DC List Archives 2005 2005-08 Page Template question / David Diskin <david.diskin@verizon.net>
Navigation
Log in


Forgot your password?
New user?
Mailing Lists
You can read our ZPUGDC mailing list archives online.
You can subscribe to our mailing list:
Book Review

The Definitive Guide to Plone

Reviewer: joel
 

Page Template question / David Diskin <david.diskin@verizon.net>

Page Template question
David Diskin <david.diskin(at)verizon.net>
2005-08-12 23:53:15 [ FULL ]
In a zope page template, I'm looping thru results from a  
portal_catalog query and writing out a table row for each result  
object.  I also want to keep a running total of a few  variables to  
write out at the end - the last row of the table.  Any suggestions on  
how to do this?  I suspect I have to use the request object, but in  
looking at the class Request.py, I see a set(name,value) method but  
not a corresponding get.  Am I missing something?   This must be a  
common use case.   Thanks much.

David
==============================
David Diskin, david.diskin(at)verizon.net

Re: [ZPUGDC] Page Template question / Jules <jules@jules.com>

Re: [ZPUGDC] Page Template question
Jules <jules(at)jules.com>
2005-08-13 08:09:29 [ FULL ]
Hey, David.

Define the variables with a tal:define and then assign them as you go 
along.

<span tal:repeat="x python:range(1,11)"
	tal:define="y int:6">
	<p tal:define="z python:x*y">
		<span tal:replace="x"/> x <span tal:replace="y"/> = <span 
tal:replace="z"/>
	</p>
</span>

So, in the first span we define y and then change it as the loop rolls 
over the range.

HTH.
Jules

On Aug 13, 2005, at 12:55 AM, David Diskin wrote:
[...]
The Internet was stolen in 1978 from legendary programmer Jeff Minter.
  Then known as the "Minternet", it was used for the sole purpose of
  marketing Minter's creations, such as Llama Rama, Camel Wars and
  Sheep in Space.

Re: [ZPUGDC] Page Template question / David Diskin <david.diskin@verizon.net>

Re: [ZPUGDC] Page Template question
David Diskin <david.diskin(at)verizon.net>
2005-08-13 09:30:03 [ FULL ]
hi Jules,

Thanks for your reply.   Unless I misunderstand your code below, I  
don't think this is quite what I'm after.  As I understand what  
you've written, with each repetition of x from 1 to 11, you get a new  
computation of z = x*y, where y = 6.  So, we get z = 6,12,18, etc.   
What I'm after is a running total of z ( sum of z).  So, (sum of z) =  
6, 18, 30, etc.  I want to display the (sum of z) - a total - in the  
final row of the table.

David

On Aug 13, 2005, at 9:12 AM, Jules wrote:
[...][...][...]
==============================
David Diskin, david.diskin(at)verizon.net

Re: [ZPUGDC] Page Template question / Bryan Simmons <bryan.simmons@gmail.com>

Re: [ZPUGDC] Page Template question
Bryan Simmons <bryan.simmons(at)gmail.com>
2005-08-13 15:10:32 [ FULL ]
THen define z just above the loop so that z exists outside the scope
of the loop.
Then increment or add to z in each loop.
Don't close the table until after the loop is complete.
Make the last row, just after the loop, the row that shows the total for z.
Wish I could code it up for you, but the previous example shows
plenty.  The only difference is scope and where you print z.

On 8/13/05, David Diskin <david.diskin(at)verizon.net> wrote:[...]

[...]

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: