comparison idavoll/pubsub.py @ 56:55fa890ef60b

Match backend's supported_*() methods in getFeatures() of ComponentServiceFromService. Add getFeatures() to ComponentServiceFromNodeCreationService. Fix small error in ComponentServiceFromNodeCreationService to handle not specifying the node attribute.
author Ralph Meijer <ralphm@ik.nu>
date Fri, 05 Nov 2004 17:14:42 +0000
parents 671ead538758
children 3e2e0040e3e0
comparison
equal deleted inserted replaced
55:7c4dfef5d964 56:55fa890ef60b
123 return results 123 return results
124 124
125 def getFeatures(self, node): 125 def getFeatures(self, node):
126 features = [] 126 features = []
127 127
128 affiliations = self.backend.get_supported_affiliations() 128 if not node:
129 if 'outcast' in affiliations: 129 if self.backend.supports_publisher_affiliation():
130 features.append("http://jabber.org/protocol/pubsub#outcast-affil") 130 features.append(NS_PUBSUB + "#publisher-affiliation")
131 131
132 if 'publisher' in affiliations: 132 if self.backend.supports_outcast_affiliation():
133 features.append("http://jabber.org/protocol/pubsub#publisher-affil") 133 features.append(NS_PUBSUB + "#outcast-affiliation")
134 134
135 # "http://jabber.org/protocol/pubsub#persistent-items" 135 if self.backend.supports_persistent_items():
136 features.append(NS_PUBSUB + "#persistent-items")
136 137
137 return features 138 return features
138 139
139 components.registerAdapter(ComponentServiceFromService, backend.IBackendService, component.IService) 140 components.registerAdapter(ComponentServiceFromService, backend.IBackendService, component.IService)
140 141
251 252
252 components.registerAdapter(ComponentServiceFromSubscriptionService, backend.ISubscriptionService, component.IService) 253 components.registerAdapter(ComponentServiceFromSubscriptionService, backend.ISubscriptionService, component.IService)
253 254
254 class ComponentServiceFromNodeCreationService(Service): 255 class ComponentServiceFromNodeCreationService(Service):
255 256
257 def getFeatures(self, node):
258 features = []
259
260 if not node:
261 features.append(NS_PUBSUB + "#create-nodes")
262
263 if self.backend.supports_instant_nodes():
264 features.append(NS_PUBSUB + "#instant-nodes")
265
266 return features
267
256 def componentConnected(self, xmlstream): 268 def componentConnected(self, xmlstream):
257 xmlstream.addObserver(PUBSUB_CREATE, self.onCreate) 269 xmlstream.addObserver(PUBSUB_CREATE, self.onCreate)
258 xmlstream.addObserver(PUBSUB_CONFIGURE_GET, self.onConfigureGet) 270 xmlstream.addObserver(PUBSUB_CONFIGURE_GET, self.onConfigureGet)
259 xmlstream.addObserver(PUBSUB_CONFIGURE_SET, self.onConfigureSet) 271 xmlstream.addObserver(PUBSUB_CONFIGURE_SET, self.onConfigureSet)
260 272
263 275
264 def _onCreate(self, iq): 276 def _onCreate(self, iq):
265 if iq.pubsub.options: 277 if iq.pubsub.options:
266 raise CreateNodeNotConfigurable 278 raise CreateNodeNotConfigurable
267 279
268 node = iq.pubsub.create["node"] 280 node = iq.pubsub.create.getAttribute("node")
281
269 owner = jid.JID(iq["from"]).userhostJID() 282 owner = jid.JID(iq["from"]).userhostJID()
270 283
271 d = self.backend.create_node(node, owner) 284 d = self.backend.create_node(node, owner)
272 d.addCallback(self.return_create_response, iq) 285 d.addCallback(self.return_create_response, iq)
273 return d 286 return d