comparison idavoll/pubsub.py @ 130:3d77f3808bfa

Follow API change in backend. Work around bug in xish.domish.
author Ralph Meijer <ralphm@ik.nu>
date Sun, 24 Apr 2005 17:25:33 +0000
parents 8527bce09862
children 46453af6b0c3
comparison
equal deleted inserted replaced
129:43102fecb14b 130:3d77f3808bfa
7 import backend 7 import backend
8 import storage 8 import storage
9 import xmpp_error 9 import xmpp_error
10 import disco 10 import disco
11 import data_form 11 import data_form
12
13 if issubclass(domish.SerializedXML, str):
14 # Work around bug # in twisted Xish
15 class SerializedXML(unicode):
16 """ Marker class for pre-serialized XML in the DOM. """
17
18 domish.SerializedXML = SerializedXML
12 19
13 NS_COMPONENT = 'jabber:component:accept' 20 NS_COMPONENT = 'jabber:component:accept'
14 NS_PUBSUB = 'http://jabber.org/protocol/pubsub' 21 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
15 NS_PUBSUB_EVENT = NS_PUBSUB + '#event' 22 NS_PUBSUB_EVENT = NS_PUBSUB + '#event'
16 NS_PUBSUB_ERRORS = NS_PUBSUB + '#errors' 23 NS_PUBSUB_ERRORS = NS_PUBSUB + '#errors'
58 pubsub_error = 'node-not-configurable' 65 pubsub_error = 'node-not-configurable'
59 66
60 error_map = { 67 error_map = {
61 storage.NodeNotFound: ('item-not-found', None), 68 storage.NodeNotFound: ('item-not-found', None),
62 storage.NodeExists: ('conflict', None), 69 storage.NodeExists: ('conflict', None),
63 70 storage.SubscriptionNotFound: ('not-authorized',
71 'not-subscribed'),
64 backend.NotAuthorized: ('not-authorized', None), 72 backend.NotAuthorized: ('not-authorized', None),
65 backend.NoPayloadAllowed: ('bad-request', None), 73 backend.NoPayloadAllowed: ('bad-request', None),
66 backend.PayloadExpected: ('bad-request', None), 74 backend.PayloadExpected: ('bad-request', None),
67 backend.NoInstantNodes: ('not-acceptable', None), 75 backend.NoInstantNodes: ('not-acceptable', None),
68 backend.NotImplemented: ('feature-not-implemented', None), 76 backend.NotImplemented: ('feature-not-implemented', None),
69 backend.NotSubscribed: ('not-authorized', 'requestor-not-subscribed'),
70 backend.InvalidConfigurationOption: ('not-acceptable', None), 77 backend.InvalidConfigurationOption: ('not-acceptable', None),
71 backend.InvalidConfigurationValue: ('not-acceptable', None), 78 backend.InvalidConfigurationValue: ('not-acceptable', None),
72 } 79 }
73 80
74 class Service(component.Service): 81 class Service(component.Service):
113 try: 120 try:
114 d = handler(iq) 121 d = handler(iq)
115 except: 122 except:
116 d = defer.fail() 123 d = defer.fail()
117 124
118
119 d.addCallback(self.success, iq) 125 d.addCallback(self.success, iq)
120 d.addErrback(self.error, iq) 126 d.addErrback(self.error, iq)
121 d.addCallback(self.send) 127 d.addCallback(self.send)
122 iq.handled = True 128 iq.handled = True
123 129
275 reply = domish.Element((NS_PUBSUB, "pubsub")) 281 reply = domish.Element((NS_PUBSUB, "pubsub"))
276 entity = reply.addElement("entity") 282 entity = reply.addElement("entity")
277 entity["node"] = result["node"] 283 entity["node"] = result["node"]
278 entity["jid"] = subscriber.full() 284 entity["jid"] = subscriber.full()
279 entity["affiliation"] = result["affiliation"] or 'none' 285 entity["affiliation"] = result["affiliation"] or 'none'
280 entity["subscription"] = result["subscription"] 286 entity["subscription"] = result["state"]
281 return [reply] 287 return [reply]
282 288
283 def onUnsubscribe(self, iq): 289 def onUnsubscribe(self, iq):
284 self.handler_wrapper(self._onUnsubscribe, iq) 290 self.handler_wrapper(self._onUnsubscribe, iq)
285 291