comparison idavoll/pubsub.py @ 85:ec557449d1aa

Implement node retraction, with storage support for pgsql.
author Ralph Meijer <ralphm@ik.nu>
date Tue, 09 Nov 2004 16:48:20 +0000
parents f3f31aa491df
children 59378610b16e
comparison
equal deleted inserted replaced
84:34be83a0bd2e 85:ec557449d1aa
25 PUBSUB_OPTIONS_SET = PUBSUB_SET + '/options' 25 PUBSUB_OPTIONS_SET = PUBSUB_SET + '/options'
26 PUBSUB_CONFIGURE_GET = PUBSUB_GET + '/configure' 26 PUBSUB_CONFIGURE_GET = PUBSUB_GET + '/configure'
27 PUBSUB_CONFIGURE_SET = PUBSUB_SET + '/configure' 27 PUBSUB_CONFIGURE_SET = PUBSUB_SET + '/configure'
28 PUBSUB_AFFILIATIONS = PUBSUB_GET + '/affiliations' 28 PUBSUB_AFFILIATIONS = PUBSUB_GET + '/affiliations'
29 PUBSUB_ITEMS = PUBSUB_GET + '/items' 29 PUBSUB_ITEMS = PUBSUB_GET + '/items'
30 PUBSUB_RETRACT = PUBSUB_SET + '/retract'
30 31
31 class Error(Exception): 32 class Error(Exception):
32 pubsub_error = None 33 pubsub_error = None
33 stanza_error = None 34 stanza_error = None
34 msg = '' 35 msg = ''
405 print e 406 print e
406 407
407 return [reply] 408 return [reply]
408 409
409 components.registerAdapter(ComponentServiceFromItemRetrievalService, backend.IItemRetrievalService, component.IService) 410 components.registerAdapter(ComponentServiceFromItemRetrievalService, backend.IItemRetrievalService, component.IService)
411
412 class ComponentServiceFromRetractionService(Service):
413
414 def componentConnected(self, xmlstream):
415 xmlstream.addObserver(PUBSUB_RETRACT, self.onRetract)
416
417 def onRetract(self, iq):
418 self.handler_wrapper(self._onRetract, iq)
419
420 def _onRetract(self, iq):
421 try:
422 node = iq.pubsub.retract["node"]
423 except KeyError:
424 raise BadRequest
425
426 item_ids = []
427 for child in iq.pubsub.retract.children:
428 if child.__class__ == domish.Element and child.name == 'item':
429 try:
430 item_ids.append(child["id"])
431 except KeyError:
432 raise BadRequest
433
434 print item_ids
435
436 return self.backend.retract_item(node, item_ids,
437 jid.JID(iq["from"]).userhostJID())
438
439 components.registerAdapter(ComponentServiceFromRetractionService, backend.IRetractionService, component.IService)