comparison src/tmp/wokkel/rsm.py @ 1439:ea48663b2605

tmp (wokkel): pubsub response do not fail when target server doesn't handle RSM
author souliane <souliane@mailoo.org>
date Tue, 14 Jul 2015 16:41:59 +0200
parents 60c41422ee48
children 4fb3280c4568
comparison
equal deleted inserted replaced
1438:0fb5785b4c63 1439:ea48663b2605
192 @rtype: L{RSMResponse} 192 @rtype: L{RSMResponse}
193 """ 193 """
194 try: 194 try:
195 set_elt = element.elements(NS_RSM, 'set').next() 195 set_elt = element.elements(NS_RSM, 'set').next()
196 except StopIteration: 196 except StopIteration:
197 return RSMNotFoundError() 197 raise RSMNotFoundError()
198 198
199 response = RSMResponse() 199 response = RSMResponse()
200 for elt in list(set_elt.elements()): 200 for elt in list(set_elt.elements()):
201 if elt.name in ('first', 'last'): 201 if elt.name in ('first', 'last'):
202 setattr(response, elt.name, ''.join(elt.children)) 202 setattr(response, elt.name, ''.join(elt.children))
329 if iq.pubsub.items: 329 if iq.pubsub.items:
330 for element in iq.pubsub.items.elements(pubsub.NS_PUBSUB, 'item'): 330 for element in iq.pubsub.items.elements(pubsub.NS_PUBSUB, 'item'):
331 items.append(element) 331 items.append(element)
332 332
333 if request.rsm: 333 if request.rsm:
334 response = RSMResponse.parse(iq.pubsub) 334 try:
335 if response is not None: 335 response = RSMResponse.parse(iq.pubsub)
336 self._rsm_responses[ext_data['id']] = response 336 if response is not None:
337 self._rsm_responses[ext_data['id']] = response
338 except RSMNotFoundError: # target pubsub server doesn't support RSM
339 pass
337 return items 340 return items
338 341
339 d = request.send(self.xmlstream) 342 d = request.send(self.xmlstream)
340 d.addCallback(cb) 343 d.addCallback(cb)
341 return d 344 return d