Code

Ticket #4558: xml_serializer.py.diff

File xml_serializer.py.diff, 1.0 KB (added by Bill Fenner <fenner@…>, 7 years ago)

Diff to XML serializer to check for the presence of a <None/> node

Line 
1--- core/serializers/xml_serializer.py.orig     2007-03-15 03:44:44.000000000 -0400
2+++ core/serializers/xml_serializer.py  2007-06-13 20:12:20.000000000 -0400
3@@ -164,7 +164,7 @@
4             elif field.rel and isinstance(field.rel, models.ManyToOneRel):
5                 data[field.attname] = self._handle_fk_field_node(field_node, field)
6             else:
7-                if len(field_node.childNodes) == 1 and field_node.childNodes[0].nodeName == 'None':
8+                if field_node.getElementsByTagName('None'):
9                     value = None
10                 else:
11                     value = field.to_python(getInnerText(field_node).strip().encode(self.encoding))
12@@ -178,7 +178,7 @@
13         Handle a <field> node for a ForeignKey
14         """
15         # Check if there is a child node named 'None', returning None if so.
16-        if len(node.childNodes) == 1 and node.childNodes[0].nodeName == 'None':
17+        if node.getElementsByTagName('None'):
18             return None
19         else:
20             return field.rel.to._meta.pk.to_python(