[Zope] return type of methods for use in "in" tag
Heiko Stoermer
heiko@mig.net
Mon, 06 Sep 1999 00:19:29 +0200
Pavlos Christoforou wrote:
> 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
this worked right out of the box! (I was a little astonished that you can
acces properties a class does not have, but o.k., that's python I guess.)
thanks a lot.
Heiko
--
Heiko Stoermer
MIG Augsburg