Mercurial > libervia-pubsub
comparison idavoll/pubsub.py @ 134:46453af6b0c3
Add a number of discovery features.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Sun, 24 Apr 2005 17:46:18 +0000 |
parents | 3d77f3808bfa |
children | d2c18d88f618 |
comparison
equal
deleted
inserted
replaced
133:229c6f6cd754 | 134:46453af6b0c3 |
---|---|
138 | 138 |
139 if not node: | 139 if not node: |
140 info.append(disco.Identity('pubsub', 'generic', | 140 info.append(disco.Identity('pubsub', 'generic', |
141 'Generic Pubsub Service')) | 141 'Generic Pubsub Service')) |
142 | 142 |
143 info.append(disco.Feature(NS_PUBSUB + "#meta-data")) | |
144 | |
145 if self.backend.supports_outcast_affiliation(): | |
146 info.append(disco.Feature(NS_PUBSUB + "#outcast-affiliation")) | |
147 | |
148 if self.backend.supports_persistent_items(): | |
149 info.append(disco.Feature(NS_PUBSUB + "#persistent-items")) | |
150 | |
143 if self.backend.supports_publisher_affiliation(): | 151 if self.backend.supports_publisher_affiliation(): |
144 info.append(disco.Feature(NS_PUBSUB + "#publisher-affiliation")) | 152 info.append(disco.Feature(NS_PUBSUB + "#publisher-affiliation")) |
145 | |
146 if self.backend.supports_outcast_affiliation(): | |
147 info.append(disco.Feature(NS_PUBSUB + "#outcast-affiliation")) | |
148 | |
149 if self.backend.supports_persistent_items(): | |
150 info.append(disco.Feature(NS_PUBSUB + "#persistent-items")) | |
151 | 153 |
152 return defer.succeed(info) | 154 return defer.succeed(info) |
153 else: | 155 else: |
154 try: | 156 try: |
155 d = self.backend.get_node_type(node) | 157 d = self.backend.get_node_type(node) |
428 | 430 |
429 class ComponentServiceFromAffiliationsService(Service): | 431 class ComponentServiceFromAffiliationsService(Service): |
430 | 432 |
431 def componentConnected(self, xmlstream): | 433 def componentConnected(self, xmlstream): |
432 xmlstream.addObserver(PUBSUB_AFFILIATIONS, self.onAffiliations) | 434 xmlstream.addObserver(PUBSUB_AFFILIATIONS, self.onAffiliations) |
435 | |
436 def get_disco_info(self, node): | |
437 info = [] | |
438 | |
439 if not node: | |
440 info.append(disco.Feature(NS_PUBSUB + "#retrieve-affiliations")) | |
441 | |
442 return defer.succeed(info) | |
433 | 443 |
434 def onAffiliations(self, iq): | 444 def onAffiliations(self, iq): |
435 self.handler_wrapper(self._onAffiliations, iq) | 445 self.handler_wrapper(self._onAffiliations, iq) |
436 | 446 |
437 def _onAffiliations(self, iq): | 447 def _onAffiliations(self, iq): |
515 def get_disco_info(self, node): | 525 def get_disco_info(self, node): |
516 info = [] | 526 info = [] |
517 | 527 |
518 if not node: | 528 if not node: |
519 info.append(disco.Feature(NS_PUBSUB + "#delete-any")) | 529 info.append(disco.Feature(NS_PUBSUB + "#delete-any")) |
530 info.append(disco.Feature(NS_PUBSUB + "#retract-items")) | |
531 info.append(disco.Feature(NS_PUBSUB + "#purge-nodes")) | |
520 | 532 |
521 return defer.succeed(info) | 533 return defer.succeed(info) |
522 | 534 |
523 def onRetract(self, iq): | 535 def onRetract(self, iq): |
524 self.handler_wrapper(self._onRetract, iq) | 536 self.handler_wrapper(self._onRetract, iq) |
561 | 573 |
562 def componentConnected(self, xmlstream): | 574 def componentConnected(self, xmlstream): |
563 self.backend.register_pre_delete(self._pre_delete) | 575 self.backend.register_pre_delete(self._pre_delete) |
564 xmlstream.addObserver(PUBSUB_DELETE, self.onDelete) | 576 xmlstream.addObserver(PUBSUB_DELETE, self.onDelete) |
565 | 577 |
578 def get_disco_info(self, node): | |
579 info = [] | |
580 | |
581 if not node: | |
582 info.append(disco.Feature(NS_PUBSUB + "#delete-nodes")) | |
583 | |
584 return defer.succeed(info) | |
585 | |
566 def _pre_delete(self, node_id): | 586 def _pre_delete(self, node_id): |
567 d = self.backend.get_subscribers(node_id) | 587 d = self.backend.get_subscribers(node_id) |
568 d.addCallback(self._return_deferreds, node_id) | 588 d.addCallback(self._return_deferreds, node_id) |
569 return d | 589 return d |
570 | 590 |