[Zope] assignment to form records

Fernando Martins fmartins@hetnet.nl
Wed, 5 Mar 2003 00:54:27 +0100


Thanks for replying,

From: Dylan Reinhardt
> Fernando Martins wrote:
> >I've a script who gets two parameters from a form: Code (int), Fields
> >(record).
>
> Record?  Haven't heard of *that* data type...
>

Well, I don't know if it is really a data type. In the zope book it's called
parameter conversion, you know, to convert string values from the form to
some other Python data type. I was assuming 'record' would convert to some
(unknown?)  class.

> >Fields.a_field = 1
> >
> >I get the error:
> >
> > > Error Type: TypeError
> > > Error Value: attribute-less object (assign or del)
>
> That's because whatever it is you're passing in for the value of Fields
> doesn't have the attribute you're attempting to assign to.
>

This works ok (in a right-hand side expression):

print Fields.a_field

> If Fields is a mapping (like REQUEST.form), you may want:
>
> Fields['a_field'] = 1
>
> If that's not it, could you provide a bit more info on what's getting
> passed in for Fields?
>

Sure, in the form I've stuff like:

<input type="text" name="Fields.Title:record">
<input type="text" name="Fields.Author:record">
etc...

I can _use_ expressions like Fields.Title in the Python script but I can't
modify it.

Cheers,
Fernando