comparison idavoll/gateway.py @ 210:2a0a6a671776

Fix error reporting for older Python versions.
author Ralph Meijer <ralphm@ik.nu>
date Fri, 30 Jan 2009 15:27:33 +0000
parents 7f3ffb7a1a9e
children bfc198af5d27
comparison
equal deleted inserted replaced
209:7f3ffb7a1a9e 210:2a0a6a671776
66 raise XMPPURIParseError("Empty URI path component") 66 raise XMPPURIParseError("Empty URI path component")
67 67
68 try: 68 try:
69 service = JID(entity) 69 service = JID(entity)
70 except Exception, e: 70 except Exception, e:
71 raise XMPPURIParseError("Invalid JID: %s" % e.message) 71 raise XMPPURIParseError("Invalid JID: %s" % e)
72 72
73 params = cgi.parse_qs(query) 73 params = cgi.parse_qs(query)
74 74
75 try: 75 try:
76 nodeIdentifier = params['node'][0] 76 nodeIdentifier = params['node'][0]
199 "Node not found") 199 "Node not found")
200 200
201 def trapXMPPURIParseError(failure): 201 def trapXMPPURIParseError(failure):
202 failure.trap(XMPPURIParseError) 202 failure.trap(XMPPURIParseError)
203 return http.StatusResponse(responsecode.BAD_REQUEST, 203 return http.StatusResponse(responsecode.BAD_REQUEST,
204 "Malformed XMPP URI: %s" % failure.value.message) 204 "Malformed XMPP URI: %s" % failure.value)
205 205
206 data = [] 206 data = []
207 d = readStream(request.stream, data.append) 207 d = readStream(request.stream, data.append)
208 d.addCallback(gotStream) 208 d.addCallback(gotStream)
209 d.addCallback(doDelete, data) 209 d.addCallback(doDelete, data)
289 "Node not found") 289 "Node not found")
290 290
291 def trapXMPPURIParseError(failure): 291 def trapXMPPURIParseError(failure):
292 failure.trap(XMPPURIParseError) 292 failure.trap(XMPPURIParseError)
293 return http.StatusResponse(responsecode.BAD_REQUEST, 293 return http.StatusResponse(responsecode.BAD_REQUEST,
294 "Malformed XMPP URI: %s" % failure.value.message) 294 "Malformed XMPP URI: %s" % failure.value)
295 295
296 self.checkMediaType(request) 296 self.checkMediaType(request)
297 d = self.parseXMLPayload(request.stream) 297 d = self.parseXMLPayload(request.stream)
298 d.addCallback(doPublish) 298 d.addCallback(doPublish)
299 d.addCallback(toResponse) 299 d.addCallback(toResponse)
599 self.params = simplejson.loads(data) 599 self.params = simplejson.loads(data)
600 600
601 def trapXMPPURIParseError(failure): 601 def trapXMPPURIParseError(failure):
602 failure.trap(XMPPURIParseError) 602 failure.trap(XMPPURIParseError)
603 return http.StatusResponse(responsecode.BAD_REQUEST, 603 return http.StatusResponse(responsecode.BAD_REQUEST,
604 "Malformed XMPP URI: %s" % failure.value.message) 604 "Malformed XMPP URI: %s" % failure.value)
605 605
606 d = readStream(request.stream, storeParams) 606 d = readStream(request.stream, storeParams)
607 d.addCallback(gotRequest) 607 d.addCallback(gotRequest)
608 d.addCallback(respond) 608 d.addCallback(respond)
609 d.addErrback(trapNotFound) 609 d.addErrback(trapNotFound)