Mercurial > libervia-pubsub
comparison idavoll/pubsub.py @ 98:b9c449f4c167
Removed debugging junk
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Wed, 24 Nov 2004 20:08:28 +0000 |
parents | cf918d581da5 |
children | b75fcc554358 |
comparison
equal
deleted
inserted
replaced
97:cf918d581da5 | 98:b9c449f4c167 |
---|---|
165 items = object["items"] | 165 items = object["items"] |
166 d = self.backend.get_notification_list(node_id, items) | 166 d = self.backend.get_notification_list(node_id, items) |
167 d.addCallback(self._notify, node_id) | 167 d.addCallback(self._notify, node_id) |
168 | 168 |
169 def _notify(self, list, node_id): | 169 def _notify(self, list, node_id): |
170 print list | |
171 for recipient, items in list.items(): | 170 for recipient, items in list.items(): |
172 self._notify_recipient(recipient, node_id, items) | 171 self._notify_recipient(recipient, node_id, items) |
173 | 172 |
174 def _notify_recipient(self, recipient, node_id, itemlist): | 173 def _notify_recipient(self, recipient, node_id, itemlist): |
175 message = domish.Element((NS_COMPONENT, "message")) | 174 message = domish.Element((NS_COMPONENT, "message")) |
204 | 203 |
205 items = [] | 204 items = [] |
206 for child in iq.pubsub.publish.children: | 205 for child in iq.pubsub.publish.children: |
207 if child.__class__ == domish.Element and child.name == 'item': | 206 if child.__class__ == domish.Element and child.name == 'item': |
208 items.append(child) | 207 items.append(child) |
209 | |
210 print items | |
211 | 208 |
212 return self.backend.publish(node, items, | 209 return self.backend.publish(node, items, |
213 jid.JID(iq["from"]).userhostJID()) | 210 jid.JID(iq["from"]).userhostJID()) |
214 | 211 |
215 components.registerAdapter(ComponentServiceFromPublishService, backend.IPublishService, component.IService) | 212 components.registerAdapter(ComponentServiceFromPublishService, backend.IPublishService, component.IService) |
393 | 390 |
394 for element in form.elements(): | 391 for element in form.elements(): |
395 if element.name == 'field' and element.uri == NS_X_DATA: | 392 if element.name == 'field' and element.uri == NS_X_DATA: |
396 options[element["var"]] = str(element.value) | 393 options[element["var"]] = str(element.value) |
397 | 394 |
398 print options | |
399 return options | 395 return options |
400 | 396 |
401 components.registerAdapter(ComponentServiceFromNodeCreationService, backend.INodeCreationService, component.IService) | 397 components.registerAdapter(ComponentServiceFromNodeCreationService, backend.INodeCreationService, component.IService) |
402 | 398 |
403 class ComponentServiceFromAffiliationsService(Service): | 399 class ComponentServiceFromAffiliationsService(Service): |
471 | 467 |
472 def _return_items_response(self, result, node_id): | 468 def _return_items_response(self, result, node_id): |
473 reply = domish.Element((NS_PUBSUB, 'pubsub')) | 469 reply = domish.Element((NS_PUBSUB, 'pubsub')) |
474 items = reply.addElement('items') | 470 items = reply.addElement('items') |
475 items["node"] = node_id | 471 items["node"] = node_id |
476 try: | 472 for r in result: |
477 for r in result: | 473 items.addRawXml(r) |
478 items.addRawXml(r) | |
479 except Exception, e: | |
480 print e | |
481 | 474 |
482 return [reply] | 475 return [reply] |
483 | 476 |
484 components.registerAdapter(ComponentServiceFromItemRetrievalService, backend.IItemRetrievalService, component.IService) | 477 components.registerAdapter(ComponentServiceFromItemRetrievalService, backend.IItemRetrievalService, component.IService) |
485 | 478 |
512 try: | 505 try: |
513 item_ids.append(child["id"]) | 506 item_ids.append(child["id"]) |
514 except KeyError: | 507 except KeyError: |
515 raise BadRequest | 508 raise BadRequest |
516 | 509 |
517 print item_ids | |
518 | |
519 return self.backend.retract_item(node, item_ids, | 510 return self.backend.retract_item(node, item_ids, |
520 jid.JID(iq["from"]).userhostJID()) | 511 jid.JID(iq["from"]).userhostJID()) |
521 | 512 |
522 def onPurge(self, iq): | 513 def onPurge(self, iq): |
523 self.handler_wrapper(self._onPurge, iq) | 514 self.handler_wrapper(self._onPurge, iq) |
558 event = message.addElement((NS_PUBSUB_EVENT, "event")) | 549 event = message.addElement((NS_PUBSUB_EVENT, "event")) |
559 event.addElement("delete")["node"] = node_id | 550 event.addElement("delete")["node"] = node_id |
560 | 551 |
561 for subscriber in subscribers: | 552 for subscriber in subscribers: |
562 message["to"] = subscriber | 553 message["to"] = subscriber |
563 print message.toXml() | |
564 self.send(message) | 554 self.send(message) |
565 | 555 |
566 def onDelete(self, iq): | 556 def onDelete(self, iq): |
567 self.handler_wrapper(self._onDelete, iq) | 557 self.handler_wrapper(self._onDelete, iq) |
568 | 558 |