[ZPT] Content/Pres w/ Loops

Call Me Audrey callmeaudrey@hotmail.com
Tue, 23 Apr 2002 16:17:03 -0400


I'm also having a content/presentation problem -- using loops. I'm trying to 
build a script that will generate a dynamic table to use in any template, 
with the number of columns to be specified by a parameter. I have the logic 
working the way I want but can't figure out how to interact with the 
template. Should I take the HTML out of the script and just return x values? 
But then wouldn't the ZPT have to access the script too many times? My brain 
is twisted up trying to figure this [cart/horse thing] out -- what's the 
basic idea behind this type of interaction? Thanks. Here's the python 
script:

#########

file_list = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]
increment = 4

## pass above variables as parameters

x = 0
y = increment

## batch in groups specifed by increment

for a in range(len(file_list)):
	if x > len(file_list) - increment:
		break
	else:
		print "<TR>"
		for i in range(x, y):
			print "<TD>"
			print file_list[i]
			print "</TD>"
		x = x + increment
		y = x + increment
#		print "x = %s" % (x)
		print "</TR>"

return printed

#########

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com