Mercurial > libervia-backend
diff src/tmp/wokkel/pubsub.py @ 2349:78c05094c349
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 | 3399971f0aa0 |
children | 6084aa557425 |
line wrap: on
line diff
--- a/src/tmp/wokkel/pubsub.py Thu Aug 24 01:11:47 2017 +0200 +++ b/src/tmp/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