Ticket #4558: xml_serializer.py.diff

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

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

  • core/serializers/xml_serializer.py

    old new  
    164164            elif field.rel and isinstance(field.rel, models.ManyToOneRel):
    165165                data[field.attname] = self._handle_fk_field_node(field_node, field)
    166166            else:
    167                 if len(field_node.childNodes) == 1 and field_node.childNodes[0].nodeName == 'None':
     167                if field_node.getElementsByTagName('None'):
    168168                    value = None
    169169                else:
    170170                    value = field.to_python(getInnerText(field_node).strip().encode(self.encoding))
     
    178178        Handle a <field> node for a ForeignKey
    179179        """
    180180        # Check if there is a child node named 'None', returning None if so.
    181         if len(node.childNodes) == 1 and node.childNodes[0].nodeName == 'None':
     181        if node.getElementsByTagName('None'):
    182182            return None
    183183        else:
    184184            return field.rel.to._meta.pk.to_python(
Back to Top