Code

Opened 8 years ago

Closed 7 years ago

#2650 closed defect (invalid)

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

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

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by ben.khoo@…

A potential patch

comment:1 Changed 8 years ago by anonymous

  • Summary changed from XML Serialization of None TextFields does not use the <None/> tag to [patch] XML Serialization of None TextFields does not use the <None/> tag

Changed 8 years ago by ben.khoo@…

Modification to the XML serializer to correctly encode the tag

comment:2 Changed 8 years ago by mtredinnick

  • Summary changed from [patch] XML Serialization of None TextFields does not use the <None/> tag to XML 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 7 years ago by Simon G. <dev@…>

  • Resolution set to invalid
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.