ZTutils marshalling functions

Bug #143335 reported by Benoît PIN
10
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Wishlist
Unassigned

Bug Description

ZTUtils.make_hidden_input and url_query don't correctly build hidden fields or urls based on nested list and dictionnary forms. This bug comes from marshalling functions implementations which are not recursive enough.

For example, this form:

> <form>
> <input type="text" value="a token field" name="rec2.a:tokens:records">
> <textarea name="rec2.b:utf8:ulines:list:records"
> >First line
> Second
> c⒜✔❀ϚτЄRS</textarea>
> <input type="text" name="rec2.b:date:list:records" value="2004/22/09 10:15">
> <input type="text" name="rec2.b:float:list:records" value="33.33">
> <textarea name="a_list:lines:list">
> One
> Two
> Three</textarea><br>
> <input name="a_list:float:list" value="0.01">
> </form>

The REQUEST.form variable built by ZPublisher will be like this :

rec2 = [{'a': ['a', 'token', 'field'], 'b': [[u'First line', u'Second', u'c\u249c\u2714\u2740\u03da\u03c4\u0404RS'], DateTime('2004/09/22 10:15:00 GMT+2'), 33.329999999999998]}]
a_list = [['One', 'Two', 'Three'], 0.01]

And, if you want to regenerate the form with the make_hidden_input function, the (wrong) result looks like as follows: nested lists and dictionnaries are rendered as raw strings, so input data types are lost.

> <input type="hidden" name="rec2:list" value="a: ['a', 'token', 'field'], b: [[u'First line', u'Second', u'c\u249c\u2714\u2740\u03da\u03c4\u0404RS'], DateTime('2004/09/22 10:15:00 GMT+2'), 33.329999999999998]">
> <input type="hidden" name="a_list:list" value="['One', 'Two', 'Three']">
> <input type="hidden" name="a_list:float:list" value="0.01">

If you install the attached hotfix, the result will be :

> <input type="hidden" name="rec2.a:list:records" value="a">
> <input type="hidden" name="rec2.a:list:records" value="token">
> <input type="hidden" name="rec2.a:list:records" value="field">
> <input type="hidden" name="rec2.b:utf8:ulines:list:records" value="First line
> Second
> c⒜✔❀ϚτЄRS">
> <input type="hidden" name="rec2.b:date:list:records" value="2004/09/22 10:15:00 GMT+2">
> <input type="hidden" name="rec2.b:float:list:records" value="33.33">
> <input type="hidden" name="a_list:tokens:list" value="One Two Three">
> <input type="hidden" name="a_list:float:list" value="0.01">

You can see on this example that marshalling operators on output forms are not necessary identical to the primary forms, but they keep the semantics.

Revision history for this message
Benoît PIN (pinbe) wrote :
Changed in zope2:
importance: Medium → Wishlist
Changed in zope2:
status: New → Confirmed
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: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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