Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HostMeta resource is being output as printable representation of xml.dom.minidom.Document instance #3

Open
paulosman opened this issue Aug 14, 2010 · 0 comments

Comments

@paulosman
Copy link
Contributor

First of all, thanks for writing python-xrd and django-wellknown and making them available. Saved me a huge amount of time / effort.

Steps to reproduce:

  1. Install and configure django-wellknown
  2. Manually address http://github.com/jcarbaugh/django-wellknown/issues/issue/2
  3. Make a request to http://localhost:8000/.well-known/host-meta

Example output:

HTTP/1.0 200 OK
Date: Sat, 14 Aug 2010 03:27:58 GMT
Server: WSGIServer/0.1 Python/2.6.5
Content-Type: application/xrd+xml

<xml.dom.minidom.Document instance at 0x2a6e6c8>

Expected:

HTTP/1.0 200 OK
Date: Sat, 14 Aug 2010 03:51:25 GMT
Server: WSGIServer/0.1 Python/2.6.5
Content-Type: application/xrd+xml

<?xml version="1.0" ?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/ns/1.0">
    <hm:Host>example.com</hm:Host>
</XRD>

I didn't know whether to create this issue against python-xrd or django-wellknown, so bear with me. The core issue is that the default handler for the host-meta resource, wellknown.resources.HostMeta returns an xml.dom.minidom.Document instance instead of the XML that the DOM represents as a string. This is because the __call__ method returns the result of XRD.to_xml which in turn returns an xml.dom.minidom.Document instance.

So, depending on what you see as the source of the problem, there are a few different ways to fix this specific problem:

  1. Modify the _render_xml function in xrd.py of python-xrd to return XML instead of an xml.dom.minidom.Document instance:
def _render_xml(xrd):
    ...
    return doc.toxml()
  1. Modify the to_xml method of the XRD class in xrd.py to return XML:
def to_xml(self):
    doc = _render_xml(self)
    return doc.toxml()
  1. Modify the __call__ method in the HostMeta class in resources.py to do the call:
def __call__(self, *args, **kwargs):
    doc = self.to_xml()
    return doc.toxml()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant