Define a request parameters API that checks the param types

Bug #110633 reported by Francis J. Lacoste
2
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Medium
Francis J. Lacoste

Bug Description

Form parameters are available in Zope3 in the request.form attribute. This attribute is a simple dictionary. But the types of the parameter can change based on the request. For example, if the parameter was specified more than once, it will be a list, otherwise a plan string (modulo the other automatic conversion done by python cgi module.)

This means that each call site should check that the parameter is a string or a list depending on what it expects. Otherwise, an error is sure to be raised... eventually. (See bug 57474 for an example.)

We should define a new form attribute that supports a getOne() and getAll() methods that make sure that the parameter is of the expected type. These methods would take care of raising UnexpectedFormData (which is the only appropriate exception to raise in that case).

Changed in launchpad:
assignee: nobody → flacoste
importance: Undecided → Medium
status: Unconfirmed → Confirmed
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Work started on this.

Changed in launchpad:
status: Confirmed → In Progress
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

API was commited in RF 4222.

Still need to integrate it to standard zope widgets.

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

See also bug #117958.

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

In review.

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Fixed in RF 4401.

Changed in launchpad:
status: In Progress → Fix Committed
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Rolled out with 1.1.6.

Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.