Mercurial > sat_tmp
diff 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 |
line wrap: on
line diff
--- 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