[Zope] Change form data in request

Dieter Maurer dieter@handshake.de
Fri, 11 Jul 2003 20:49:04 +0200


Paolo Dina wrote at 2003-7-11 16:26 +0200:
 > I know that the request object stores all the informations about the 
 > current request, i.e. cookies, server data, form data and input headers.
 > 
 > So, i get request using this syntax:
 > r = context.request
 > And using .set it is possible to change values of variables stored in 
 > request.
 > Now the question: why
 > 
 > r.set( 'name', 'newvalue' ) # changes a variable in 'option' section 
 > of request
 > works, and
 > 
 > r.set( r.form[ 'variable_in_form' ], 'newvalue' )
 > does not?

It does, but probably in a different way as you expect:

   It sets the variable with name obtained by evaluating
   "r.form['variable_in_form']" to 'newvalue'.

When you want to change the variable in the form itself,
you can use:

    r.form.update({'variable_in_form' : 'newvalue'})


Dieter