Opened 18 years ago

Closed 18 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: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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@… 18 years ago.
A potential patch
xml_serializer.py (8.0 KB ) - added by ben.khoo@… 18 years ago.
Modification to the XML serializer to correctly encode the tag

Download all attachments as: .zip

Change History (5)

by ben.khoo@…, 18 years ago

Attachment: base.py added

A potential patch

comment:1 by anonymous, 18 years ago

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

by ben.khoo@…, 18 years ago

Attachment: xml_serializer.py added

Modification to the XML serializer to correctly encode the tag

comment:2 by Malcolm Tredinnick, 18 years ago

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 by Simon G. <dev@…>, 18 years ago

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