# HG changeset patch # User Goffi # Date 1503857699 -7200 # Node ID f9d14d3d0835755b7057d9be2d9bc2b3bced92ab # Parent 03224edb88af3bb5a09502f6c47dad740511cf3c tmp(wokkel/pubsub): allows getNodes to return names using tuples(node/names) diff -r 03224edb88af -r f9d14d3d0835 wokkel/pubsub.py --- a/wokkel/pubsub.py Sun Aug 20 10:29:26 2017 +0200 +++ b/wokkel/pubsub.py Sun Aug 27 20:14:59 2017 +0200 @@ -1289,6 +1289,22 @@ return d + def _parseNodes(self, nodes, target): + """parse return values of resource.getNodes + + basestring values are used as node + tuple are unpacked as node, name + """ + items = [] + for node in nodes: + if isinstance(node, basestring): + items.append(disco.DiscoItem(target, node)) + else: + _node, name = node + items.append(disco.DiscoItem(target, _node, name)) + return items + + def getDiscoItems(self, requestor, target, nodeIdentifier=''): if self.hideNodes: d = defer.succeed([]) @@ -1301,8 +1317,7 @@ else: d = defer.succeed([]) - d.addCallback(lambda nodes: [disco.DiscoItem(target, node) - for node in nodes]) + d.addCallback(self._parseNodes, target) return d