def request(self, tree, **kwargs):
apirequest = lxml.etree.tostring(<EOL>E.openXML(<EOL>E.credentials(<EOL>E.username(self.username),<EOL>OE('<STR_LIT:password>', self.password),<EOL>OE('<STR_LIT>', self.password_hash),<EOL>),<EOL>tree<EOL>),<EOL>method='<STR_LIT>'<EOL>)<EOL>try:<EOL><INDENT>apiresponse = self.session.post(self.url, data=apirequest)<EOL>apiresponse.raise_for_status()<EOL><DEDENT>except requests.RequestException as e:<EOL><INDENT>raise ServiceUnavailable(str(e))<EOL><DEDENT>tree = lxml.objectify.fromstring(apiresponse.content)<EOL>if tree.reply.code == <NUM_LIT:0>:<EOL><INDENT>return Response(tree)<EOL><DEDENT>else:<EOL><INDENT>klass = from_code(tree.reply.code)<EOL>desc = tree.reply.desc<EOL>code = tree.reply.code<EOL>data = getattr(tree.reply, '<STR_LIT:data>', '<STR_LIT>')<EOL>raise klass(u"<STR_LIT>".format(desc, code, data), code)<EOL><DEDENT>
Construct a new request with the given tree as its contents, then ship
it to the OpenProvider API.