changeset 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 18d71226b3a8
children 388226e9c3ff
files src/tmp/wokkel/pubsub.py
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
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