Mercurial > libervia-pubsub
comparison idavoll/pubsub.py @ 18:7937d6fbbe2a
Small code cleanups
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Mon, 30 Aug 2004 17:41:18 +0000 |
parents | ce3d0db64da1 |
children | e01bbbfa8a46 |
comparison
equal
deleted
inserted
replaced
17:0861c0f2e3b5 | 18:7937d6fbbe2a |
---|---|
72 raise | 72 raise |
73 | 73 |
74 def success(self, result, iq): | 74 def success(self, result, iq): |
75 iq.swapAttributeValues("to", "from") | 75 iq.swapAttributeValues("to", "from") |
76 iq["type"] = 'result' | 76 iq["type"] = 'result' |
77 iq.children = [] | 77 iq.children = result or [] |
78 return iq | 78 return iq |
79 | 79 |
80 def notImplemented(self, iq): | 80 def notImplemented(self, iq): |
81 self.send(xmpp_error.error_from_iq(iq, 'feature-not-implemented')) | 81 self.send(xmpp_error.error_from_iq(iq, 'feature-not-implemented')) |
82 | 82 |
112 def onSubscribe(self, iq): | 112 def onSubscribe(self, iq): |
113 node_id = iq.pubsub.subscribe["node"] | 113 node_id = iq.pubsub.subscribe["node"] |
114 subscriber = jid.JID(iq.pubsub.subscribe["jid"]) | 114 subscriber = jid.JID(iq.pubsub.subscribe["jid"]) |
115 requestor = jid.JID(iq["from"]).userhostJID() | 115 requestor = jid.JID(iq["from"]).userhostJID() |
116 d = self.backend.do_subscribe(node_id, subscriber, requestor) | 116 d = self.backend.do_subscribe(node_id, subscriber, requestor) |
117 d.addCallback(self.return_subscription, iq) | 117 d.addCallback(self.return_subscription) |
118 d.addCallback(self.succeed, iq) | |
118 d.addErrback(self.error, iq) | 119 d.addErrback(self.error, iq) |
119 d.addCallback(self.send) | 120 d.addCallback(self.send) |
120 | 121 |
121 def return_subscription(self, result, iq): | 122 def return_subscription(self, result): |
122 reply = self.success(result, iq) | 123 reply = domish.Element("pubsub", NS_PUBSUB) |
123 entity = reply.addElement("entity") | 124 entity = reply.addElement("entity") |
124 entity["node"] = result["node"] | 125 entity["node"] = result["node"] |
125 entity["jid"] = result["jid"].full() | 126 entity["jid"] = result["jid"].full() |
126 entity["affiliation"] = result["affiliation"] | 127 entity["affiliation"] = result["affiliation"] |
127 entity["subscription"] = result["subscription"] | 128 entity["subscription"] = result["subscription"] |
128 return iq | 129 return reply |
129 | 130 |
130 def do_notification(self, list, node): | 131 def do_notification(self, list, node): |
131 | 132 |
132 for recipient, items in list.items(): | 133 for recipient, items in list.items(): |
133 self.notify(node, items, recipient) | 134 self.notify(node, items, recipient) |