[Zope] How should a collection be in a Python product if i want to trave rse it with <dtml-in> rse it with <dtml-in>

Max Møller Rasmussen maxm@normik.dk
Wed, 25 Oct 2000 14:10:52 +0200


This is a question I guess has something to do with popping an object onto
the namespace, or about me not understanding how stuff works.

When I make a list of objects:

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>

But it isn't so. What do I need to do to make the objects namespace count in
my traversal? (I'd like to keep the dtml as simple as possible.)

--------------

If I make a list:

theList = [1, 2, 3, 4]

I can traverse it with:
<dtml-in theList>
    <dtml-var sequence-item>
</dtml in>

---------

and if it's a list if dicts:

theList = [{'value':1},{'value':2},{'value':3},{'value':4}]

I can traverse it like:

<dtml in theList>
    <dtml-let item=sequence-item>
        <dtml-var "item['value']">
    </dtml-let>
</dtml in>