[Zope] How should a collection be in a Python product if i wantto
trave rse it with <dtml-in> rse it with <dtml-in>
Chris Withers
chrisw@nipltd.com
Wed, 25 Oct 2000 16:44:08 +0100
Oleg Broytmann wrote:
>
> On Wed, 25 Oct 2000, [iso-8859-1] Max Møller Rasmussen wrote:
> > class simple:
> > def __init__(self, value):
> > self.value = value
> >
> > theList = [simple(1), simple(2), simple(3), simple(4)]
> >
> > I would expect to be able to traverse it like below (The objects namespace
> > would be popped onto the namespace.):
> >
> > <dtml-in theList>
> > <dtml-var value>
> > </dtml-in>
If you're getting security errors, try this new version (untested):
class simple(Acquisition.Implicit)
__ac__permissions__ = (
('View', ('get_value','get_list'),('Manager','Anonymous')),
)
def __init__(self,value):
self.value=value
def get_value(self):
return value
Globals.default__class_init__(simple)
Now, hopefully, theList is being returned from within a class method, in
which case:
theList = [simple(1).__of__(self), simple(2)__of__(self),
simple(3)__of__(self), simple(4)__of__(self)]
return theList
then:
<dtml-in get_theList>
<dtml-var get_value>
</dtml-in>
should work...
hmmmm,
Chris