comparison wokkel/pubsub.py @ 41:f9d14d3d0835

tmp(wokkel/pubsub): allows getNodes to return names using tuples(node/names)
author Goffi <goffi@goffi.org>
date Sun, 27 Aug 2017 20:14:59 +0200
parents 03224edb88af
children 9e784ca20e23
comparison
equal deleted inserted replaced
40:03224edb88af 41:f9d14d3d0835
1287 d.addErrback(log.err) 1287 d.addErrback(log.err)
1288 d.addCallback(lambda _: info) 1288 d.addCallback(lambda _: info)
1289 return d 1289 return d
1290 1290
1291 1291
1292 def _parseNodes(self, nodes, target):
1293 """parse return values of resource.getNodes
1294
1295 basestring values are used as node
1296 tuple are unpacked as node, name
1297 """
1298 items = []
1299 for node in nodes:
1300 if isinstance(node, basestring):
1301 items.append(disco.DiscoItem(target, node))
1302 else:
1303 _node, name = node
1304 items.append(disco.DiscoItem(target, _node, name))
1305 return items
1306
1307
1292 def getDiscoItems(self, requestor, target, nodeIdentifier=''): 1308 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
1293 if self.hideNodes: 1309 if self.hideNodes:
1294 d = defer.succeed([]) 1310 d = defer.succeed([])
1295 elif self.resource is not None: 1311 elif self.resource is not None:
1296 request = self._request_class('discoInfo') 1312 request = self._request_class('discoInfo')
1299 elif nodeIdentifier: 1315 elif nodeIdentifier:
1300 d = self.getNodes(requestor, target) 1316 d = self.getNodes(requestor, target)
1301 else: 1317 else:
1302 d = defer.succeed([]) 1318 d = defer.succeed([])
1303 1319
1304 d.addCallback(lambda nodes: [disco.DiscoItem(target, node) 1320 d.addCallback(self._parseNodes, target)
1305 for node in nodes])
1306 return d 1321 return d
1307 1322
1308 1323
1309 def _onPubSubRequest(self, iq): 1324 def _onPubSubRequest(self, iq):
1310 request = self._request_class.fromElement(iq) 1325 request = self._request_class.fromElement(iq)