def to_xml(self): author_xml = cloudaudit.control.base.\ recursively_serialize_a_list(self._authors, etree.Element("authors")) ret_xml = E.entry(E.title(self.title), E.link({"href": self.link}, {"type": self.link_type}, {"rel": self.link_rel}), E.id(self.id), E.updated(self.updated), E.content({"type": self.content_type}, {"lang": self.content_lang}, self.content), author_xml) return ret_xml
def to_full_xml_element(self, accept_language=None, fake_links=False, remove_internal_elements=False): el = super(RoadEvent, self).to_full_xml_element(accept_language, fake_links, remove_internal_elements) el.insert(0, E.status('ACTIVE' if self.active else 'ARCHIVED')) el.append(E.created(self.created.isoformat())) el.append(E.updated(self.updated.isoformat())) if not remove_internal_elements and not self.published: unpublished = etree.Element('{%s}unpublished' % NSMAP['protected'], nsmap=NSMAP) unpublished.text = 'true' el.append(unpublished) return el
def get_manifest(self, req): self.add_author("jd", "jd@sec") self.add_author("jd2", "*****@*****.**") temp_xml = \ recursively_serialize_a_list(self._authors, etree.Element("authors")) txml = temp_xml for e in self.entries: new_xml = e.to_xml() txml.append(new_xml) txml = new_xml self.xml_doc = E.feed({"xmlns": "http://www.w3.org/2005/Atom"}, E.title(self.control_title), E.link({"href": self.url}, {"rel": "self"}), E.id(self.id), E.subtitle(self.control_subtitle), E.updated(self.time_updated), E.generator({"uri": self.generated}, {"version": self.__class__.generated_vers}, self.__class__.api_name), E.rights({"term": ""}), temp_xml, E.rights({"type": "text"}, self.__class__.rights), E.category({"term": self.__class__.regime_str}, {"label": self.__class__.regime_str}), temp_xml) self.text_response = etree.tostring(self.xml_doc, pretty_print=True) self.response = Response() self.response.write(self.text_response) self.response.headers['content-type'] = 'application/xml' return self.response