[ZCM] [ZC] 1715/ 1 Request "ZTutils marshalling functions"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Mon Feb 28 10:29:40 EST 2005


Issue #1715 Update (Request) "ZTutils marshalling functions"
 Status Pending, Zope/bug+solution medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/1715

==============================================================
= Request - Entry #1 by pinbe on Feb 28, 2005 10:29 am


Uploaded:  "ZTUtils_hotfix.tar.gz"
 - http://www.zope.org/Collectors/Zope/1715/ZTUtils_hotfix.tar.gz/view
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.

==============================================================



More information about the Zope-Collector-Monitor mailing list