def _watchers_to_xml(self, watchers, uri, check_etag): root = etree.Element("watchers", nsmap={None: self.default_ns}) for watcher in watchers: watcher_elem = etree.SubElement(root, "watcher") for name, value in watcher.iteritems(): etree.SubElement(watcher_elem, name).text = value doc = etree.tostring(root, encoding="utf-8", pretty_print=True, xml_declaration=True) #self.validate_document(doc) etag = make_etag(uri, doc) check_etag(etag) return StatusResponse(200, data=doc, etag=etag)
def _get_document(self): if hasattr(self, 'doc'): return self.doc, self.etag root = etree.Element("xcap-caps", nsmap={None: self.default_ns}) auids = etree.SubElement(root, "auids") extensions = etree.SubElement(root, "extensions") namespaces = etree.SubElement(root, "namespaces") from xcap.appusage import applications for (id, app) in applications.items(): etree.SubElement(auids, "auid").text = id etree.SubElement(namespaces, "namespace").text = app.default_ns self.doc = etree.tostring(root, encoding="UTF-8", pretty_print=True, xml_declaration=True) self.etag = make_etag('xcap-caps', self.doc) return self.doc, self.etag