[Zope] Accessing individual items within a list

Passin, Tom tpassin@mitretek.org
Fri, 30 May 2003 14:15:24 -0400


[McDonnell, Larry]
>=20
> <dtml-var pbtemp[1]>
> <dtml-var pbtemp[2]>
> <dtml-var pbtemp[3]>
>=20
> I see
>=20
> aa bb cc
>=20
> I am trying to find a way to use this method but my syntax is wrong:
>=20
> <dtml-in expr=3D"_.range(3)">
>=20
> <dtml-var pbtemp[_['sequence-index']]>
>=20
> </dtml-in>
>=20
> I see the following error:
>=20
> Error Type: KeyError
> Error Value: pbtemp[_['sequence-index']]
>=20
>

It is hard to sure from what you have said, but it looks like pbtemp is
just a list of form values If so, you ought to be able to just do

<dtml-in pbtemp>
    <!-- do something with sequence-item-->
</dtml-in>


But the way you have named the form elements is strange and it is hard
to be sure just what you are getting because of that.

I am going by old memories here, but I think you should name all your
inputs the same, not with subscripts.  Just name them all pbtemp.  When
the form is returned, pbtemp will be a list, and then it will work the
way I sketched above.  To avoid the possiblility that only one value
would be returned (if the others were blank), you can force Zope to make
the result a list by naming the input elements pbtemp:list.

Cheers,

Tom P