[Zope] Need Help in Using :record Type in Form Variable

Michel Pelletier michel@digicool.com
Mon, 20 Mar 2000 23:08:31 -0800


Tanming Fong wrote:

> Now processForm need to tell which and how many choice.x:record are entered.
> This works:
>         <dtml-var "REQUEST['choice']">
> that's as far as I can go. I want to do:
>         <dtml-in "REQUEST['choice'].keys()">
>                 <dtml-var sequence-item>:<dtml-var sequence-value>
>         </dtml>
> but it doesn't know what "keys()" is.

> Question: how do I get the keys and values for this "choice" record in
> processForm?

Record objects do not implement a mapping interface.  Form elements are
turned into attributes of your 'choice' object, so your objects has
instance attributes named 1, 3, and 10.  You will need to use
_.getattr() to access these attributes since numbers are not very good
attribute names.

It might be a good idea to look into a new ZPublisher type called
:dictionary (or :mapping) that works much like :record, it would be
fairly trivial to implement, want to take a stab at it?

-Michel