[Zope] return type of methods for use in "in" tag

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Sun, 5 Sep 1999 16:26:37 -0400 (EDT)


On Sun, 5 Sep 1999, Heiko Stoermer wrote:

> a quick one:
> what type of object does an external method have to return that I want
> to call in an "in" tag?

One option (and they are many) is to return a list of instances. Then if
you iterate over the list using <dtml-in ...> the attributes of those
instances will be made available in the namespace. 

for example (untested)

class Helper:
	pass

def mymethod(self):
	out=[]
	for i in range(10):
		tmp=Helper()
		tmp.no=i
		tmp.name='spam'
		out.append(tmp)
	return out

and call it like:

> <dtml-in "mymethod">
>     <dtml-var no> <dtml-var name>
> </dtml-in>


Pavlos