Five: formlib REQUEST parameters conversion

Bug #176563 reported by Sylvain Viollon
4
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Medium
Unassigned

Bug Description

In formlib port, Five handle the conversion in the request form object of string from 'str' to 'unicode' (paying attention to IUserPreferredCharsets) in 'Products.Five.browser.decode'. But there is a problem, if a list in the form (for example coming from a multi select widget), contains other things than 'str' object, they are discarded.

And this happens if in the same page you put more than one 'form.SubPageForm', the conversion code is called twice, 'unicode' object from the previous conversion are not 'str' anymore, and are discarded (and your multi select widget becomes empty on the second form of your page).

Revision history for this message
Sylvain Viollon (thefunny) wrote :

There is two different solutions to solve this problem:

- Make a non-destructive conversion method;

- Called conversion method only one time.

Here a simple patch for the first method.

Revision history for this message
Daniel Widerin (saily) wrote :

Here's a patch for the second method. If we decide to use this one, we should make z3c.form use of the same interface. i used the same name, but it would be nice if z3c.form includes this instead of creating a new interface with the same name.

Revision history for this message
Daniel Nouri (daniel.nouri) wrote :

+1 to Sylvain's patch which seems simpler. We also need a simple test to accompany it.

BTW, Daniel Widerin means plone.z3cform when he says z3c.form. plone.z3cform has a safeguard that makes sure processInputs is only ever called once per request. This will become unnecessary once we have Sylvain's patch.

Revision history for this message
Sylvain Viollon (thefunny) wrote :

In fact, I can make a branch now, add that patch, a test, check with I don't who yet the code, and merge with the trunk of Products.Five. Objections ?

Revision history for this message
Tres Seaver (tseaver) wrote :

The proposed fixes still apply to the 2.12 branch and the trunk.

This *definitely* needs tests.

Changed in zope2:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Triaged → Invalid
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.