Opened 10 years ago

Closed 10 years ago

#2650 closed defect (invalid)

XML Serialization of None TextFields does not use the <None/> tag

Reported by: ben.khoo@… Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

There appears to be a problem serializing TextFields where the value is None.

Refer to line 62 of xml_serializer.py
The expected return value from self.get_string_value(obj, field) is either a string or None however the get_string_value method does not appear to return None when appropriate.

The result of this oversight is that TextFields where the value is None is encoded as

<field type="TextField" name="comment">None</field>

rather than

<field type="TextField" name="comment">
<None/>
</field>

Attachments (2)

base.py (4.7 KB) - added by ben.khoo@… 10 years ago.
A potential patch
xml_serializer.py (8.0 KB) - added by ben.khoo@… 10 years ago.
Modification to the XML serializer to correctly encode the tag

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by ben.khoo@…

Attachment: base.py added

A potential patch

comment:1 Changed 10 years ago by anonymous

Summary: XML Serialization of None TextFields does not use the <None/> tag[patch] XML Serialization of None TextFields does not use the <None/> tag

Changed 10 years ago by ben.khoo@…

Attachment: xml_serializer.py added

Modification to the XML serializer to correctly encode the tag

comment:2 Changed 10 years ago by Malcolm Tredinnick

Summary: [patch] XML Serialization of None TextFields does not use the <None/> tagXML Serialization of None TextFields does not use the <None/> tag

Please attach a patch against the current source, rather than the whole files. It is very difficult to work out what places you made changes to in both these files.

From what I can work out from your changes, I'm not sure it is correct. Can you please attach a test case showing that we deserialize the object correctly after making the change you propose. There might be a change needed in deserialization as well.

Removing the patch keyword for now until there is a real patch available.

comment:3 Changed 10 years ago by Simon G. <dev@…>

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top