Mercurial > libervia-pubsub
comparison idavoll/pubsub.py @ 93:ea3b2410c01c
Ignore unsupported configure and option elements.
Return pubsub#item-ids feature.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Wed, 17 Nov 2004 21:00:37 +0000 |
parents | 59378610b16e |
children | 3ad74552bbc7 |
comparison
equal
deleted
inserted
replaced
92:878a5b7697f2 | 93:ea3b2410c01c |
---|---|
44 | 44 |
45 class OptionsUnavailable(Error): | 45 class OptionsUnavailable(Error): |
46 stanza_error = 'feature-not-implemented' | 46 stanza_error = 'feature-not-implemented' |
47 pubsub_error = 'subscription-options-unavailable' | 47 pubsub_error = 'subscription-options-unavailable' |
48 | 48 |
49 class SubscriptionOptionsUnavailable(Error): | |
50 stanza_error = 'not-acceptable' | |
51 pubsub_error = 'subscription-options-unavailable' | |
52 | |
53 class NodeNotConfigurable(Error): | 49 class NodeNotConfigurable(Error): |
54 stanza_error = 'feature-not-implemented' | 50 stanza_error = 'feature-not-implemented' |
55 pubsub_error = 'node-not-configurable' | 51 pubsub_error = 'node-not-configurable' |
56 | |
57 class CreateNodeNotConfigurable(Error): | |
58 stanza_error = 'not-acceptable' | |
59 pubsub_error = 'node-not-configurable' | |
60 | |
61 | |
62 | 52 |
63 error_map = { | 53 error_map = { |
64 backend.NotAuthorized: ('not-authorized', None), | 54 backend.NotAuthorized: ('not-authorized', None), |
65 backend.NodeNotFound: ('item-not-found', None), | 55 backend.NodeNotFound: ('item-not-found', None), |
66 backend.NoPayloadAllowed: ('bad-request', None), | 56 backend.NoPayloadAllowed: ('bad-request', None), |
183 class ComponentServiceFromPublishService(Service): | 173 class ComponentServiceFromPublishService(Service): |
184 | 174 |
185 def componentConnected(self, xmlstream): | 175 def componentConnected(self, xmlstream): |
186 xmlstream.addObserver(PUBSUB_PUBLISH, self.onPublish) | 176 xmlstream.addObserver(PUBSUB_PUBLISH, self.onPublish) |
187 | 177 |
178 def get_disco_info(self, node): | |
179 info = [] | |
180 | |
181 if not node: | |
182 info.append(disco.Feature(NS_PUBSUB + "#item-ids")) | |
183 | |
184 return defer.succeed(info) | |
185 | |
188 def onPublish(self, iq): | 186 def onPublish(self, iq): |
189 self.handler_wrapper(self._onPublish, iq) | 187 self.handler_wrapper(self._onPublish, iq) |
190 | 188 |
191 def _onPublish(self, iq): | 189 def _onPublish(self, iq): |
192 node = iq.pubsub.publish["node"] | 190 node = iq.pubsub.publish["node"] |
221 | 219 |
222 def onSubscribe(self, iq): | 220 def onSubscribe(self, iq): |
223 self.handler_wrapper(self._onSubscribe, iq) | 221 self.handler_wrapper(self._onSubscribe, iq) |
224 | 222 |
225 def _onSubscribe(self, iq): | 223 def _onSubscribe(self, iq): |
226 if iq.pubsub.options: | |
227 raise SubscribeOptionsUnavailable | |
228 | |
229 try: | 224 try: |
230 node_id = iq.pubsub.subscribe["node"] | 225 node_id = iq.pubsub.subscribe["node"] |
231 subscriber = jid.JID(iq.pubsub.subscribe["jid"]) | 226 subscriber = jid.JID(iq.pubsub.subscribe["jid"]) |
232 except KeyError: | 227 except KeyError: |
233 raise BadRequest | 228 raise BadRequest |
293 | 288 |
294 def onCreate(self, iq): | 289 def onCreate(self, iq): |
295 self.handler_wrapper(self._onCreate, iq) | 290 self.handler_wrapper(self._onCreate, iq) |
296 | 291 |
297 def _onCreate(self, iq): | 292 def _onCreate(self, iq): |
298 if iq.pubsub.options: | |
299 raise CreateNodeNotConfigurable | |
300 | |
301 node = iq.pubsub.create.getAttribute("node") | 293 node = iq.pubsub.create.getAttribute("node") |
302 | 294 |
303 owner = jid.JID(iq["from"]).userhostJID() | 295 owner = jid.JID(iq["from"]).userhostJID() |
304 | 296 |
305 d = self.backend.create_node(node, owner) | 297 d = self.backend.create_node(node, owner) |