1. Jesper Noehr
  2. django-piston
  3. Issues
Issue #147 new

XMLEmitter renders empty elements with content 'None'

Fabian Topfstedt
created an issue

The XMLEmitter currently renders empty elements (where data is None in python) via django's smart-unicode method, but should better filter out those elements instead.

What it renders is: <no_content>None</no_content>

What it should render is: <no_content></no_content>

Comments (1)

  1. Fabian Topfstedt reporter

    Meanwhile I unregistered the shipped XMLEmitter and registered a replacement that might be interesting for other users as well:

    from piston.emitters import XMLEmitter
    class NoneSupportingXMLEmitter(XMLEmitter):
        A XML emitter that renders None values empty, not as "None".
        def _to_xml(self, xml, data, *args, **kwargs):
            if data is not None:
                super(NoneSupportingXMLEmitter, self)._to_xml(xml, data, *args,
  2. Log in to comment