def create_item(self, item): if not item.search('event'): return ewsitem = Erebus2EWSVisitor(item).run() xml = cnode2xml(ewsitem) print ToStringVisitor(with_types=True).visit(ewsitem) tmpnam= os.tmpnam() + '.xml' print "Writing query to " + tmpnam f = open(tmpnam,'w') f.write(ET.tostring(xml)) f.close() res = self.query.create_items(ET.tostring(xml)) cn = xml2cnode(ET.XML(res)) StripNamespaceVisitor().visit(cn) eid = CNode('exchange_id') itemid = cn.search('ItemId') eid.attr['id'] = itemid.attr['Id'] eid.attr['changekey'] = itemid.attr['ChangeKey'] return eid
def __conv(self,string): return xml2cnode(ET.XML(string))