Can xml_serializer deserialize a pretty-printed XML ?

37 views
Skip to first unread message

Rodrigo Senra

unread,
Jul 26, 2007, 4:45:23 PM7/26/07
to Django developers

Hi,

I seek advice if the following behavior is a bug or a feature:

xml_serialize.py generates a blank-space-free XML file, for example :
"""<field to="app.somemodel" name="somefield" rel="ManyToOneRel"><None></None></field>"""

If I pretty-print (introducing '\n') that XML file, for example into:

"""
<field to="app.somemodel" name="somefield" rel="ManyToOneRel">
<None>
</None>
</field>
"""

Then it breaks deserialization badly, because in xml_serializer.py->
method _handle_fk_field_node there is the test:

if len(node.childNodes) == 1 and node.childNodes[0].nodeName == 'None':
return None

If pretty-printing occurs, childNodes is [DomNode '\n', DomNode None, DomNode '\n'],
instead of [DomNode None], and then it breaks.

The problem __only manifests for None values__ in pretty-printed XML files.

So, what is the right conclusion:
(1) It was an accident that pretty-printed XML serialized files actually work.
The xml-serialized file should not be tempered and deserialized as it was
produced.
(2) Serialized pretty-printed xml files should work, and the None handling is a
bug.

If (1) is right, perhaps we should add a note to [1].
If (2) is right, should we open a ticket ? I could do it, but I do not have a login
in the tracker.

[1] http://www.djangoproject.com/documentation/serialization/

best regards,
Rod Senra
--
http://rodrigo.senra.nom.br

Russell Keith-Magee

unread,
Jul 26, 2007, 7:29:25 PM7/26/07
to django-d...@googlegroups.com
On 7/27/07, Rodrigo Senra <rods...@gpr.com.br> wrote:
>
> The problem __only manifests for None values__ in pretty-printed XML files.

There already is a ticket for this problem - #4558, which was fixed
(or should have been fixed) in [5727].

If you have a test case that is still failing, feel free to reopen the
ticket and attach the test case as evidence.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages