def handleRequest(self, Body='', **kwargs): yield '\r\n'.join([ 'HTTP/1.0 200 Ok', 'Content-Type: text/xml; charset=utf-8\r\n', '' ]) try: updateRequest = bind_string(Body).updateRequest recordId = str(updateRequest.recordIdentifier) normalizedRecordId = notWordCharRE.sub('_', recordId) self._number += 1 if self._number <= self._maxCountNumber: filename = '%05d_%s.updateRequest' % (self._number, normalizedRecordId) with open(join(self._dumpdir, filename), 'w') as f: print recordId stdout.flush() updateRequest.xml(f) answer = RESPONSE_XML % { "operationStatus": "success", "diagnostics": "" } else: self._maxCountNumber = self._number + self._maxCount print 'Reached maxCount' answer = RESPONSE_XML % { "operationStatus": "fail", "diagnostics": DIAGNOSTIC_XML % escapeXml("Enough is enough") } except Exception, e: answer = RESPONSE_XML % { "operationStatus": "fail", "diagnostics": DIAGNOSTIC_XML % escapeXml(format_exc()) }
def handleRequest(self, Body='', **kwargs): yield '\r\n'.join([ 'HTTP/1.0 200 OK', 'Content-Type: text/xml; charset=utf-8\r\n', '' ]) try: updateRequest = xpathFirst(XML(Body), '/ucp:updateRequest') recordId = xpathFirst(updateRequest, 'ucp:recordIdentifier/text()') normalizedRecordId = notWordCharRE.sub('_', recordId) self._number += 1 if self._number <= self._maxCountNumber: filename = '%05d_%s.updateRequest' % (self._number, normalizedRecordId) with open(join(self._dumpdir, filename), 'w') as f: print recordId stdout.flush() f.write(tostring(updateRequest)) answer = RESPONSE_XML % { "operationStatus": "success", "diagnostics": "" } else: self._maxCountNumber = self._number + self._maxCount print 'Reached maxCount of records:', self._maxCount answer = RESPONSE_XML % { "operationStatus": "fail", "diagnostics": DIAGNOSTIC_XML % { 'uri': escapeXml("http://www.enough.is.enough.com"), 'message': escapeXml("Enough is enough! Reached max. count: " + str(self._maxCount)), 'details': escapeXml( "Enough is more than enough! Reached max. count: " + str(self._maxCount)) } } except Exception, e: answer = RESPONSE_XML % { "operationStatus": "fail", "diagnostics": DIAGNOSTIC_XML % { 'uri': '', 'message': '', 'details': escapeXml(format_exc()) } }
def handleRequest(self, Body='', **kwargs): yield '\r\n'.join(['HTTP/1.0 200 OK', 'Content-Type: text/xml; charset=utf-8\r\n', '']) try: updateRequest = xpathFirst(XML(Body), '/ucp:updateRequest') recordId = xpathFirst(updateRequest, 'ucp:recordIdentifier/text()') normalizedRecordId = notWordCharRE.sub('_', recordId) self._number +=1 if self._number <= self._maxCountNumber: filename = '%05d_%s.updateRequest' %(self._number, normalizedRecordId) with open(join(self._dumpdir, filename), 'w') as f: print recordId stdout.flush() f.write(tostring(updateRequest)) answer = RESPONSE_XML % { "operationStatus": "success", "diagnostics": ""} else: self._maxCountNumber = self._number + self._maxCount print 'Reached maxCount' answer = RESPONSE_XML % { "operationStatus": "fail", "diagnostics": DIAGNOSTIC_XML % {'uri': '', 'message': '', 'details': escapeXml("Enough is enough")}} except Exception, e: answer = RESPONSE_XML % { "operationStatus": "fail", "diagnostics": DIAGNOSTIC_XML % {'uri': '', 'message': '', 'details': escapeXml(format_exc())}}