changeset 302:b8b25efae0bc

fixed item_data issues after introduction of ItemData namedtuple
author Goffi <goffi@goffi.org>
date Wed, 25 Nov 2015 22:48:59 +0100
parents 05c875a13a62
children 3c2705199108
files sat_pubsub/backend.py
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sat_pubsub/backend.py	Wed Nov 25 18:33:38 2015 +0100
+++ b/sat_pubsub/backend.py	Wed Nov 25 22:48:59 2015 +0100
@@ -595,13 +595,19 @@
         log.msg("Error while getting roster: {}".format(failure.value))
         return {}
 
+    def _tuple2ItemData(self, items_data):
+        # FIXME: workaround for the use of ItemData which doesn't exist in storage
+        #        must be done in a cleaner way
+        return [ItemData(item, access_model, access_list, []) for item, access_model, access_list in items_data]
+
     def _doGetItems(self, result, requestor, maxItems, itemIdentifiers,
                     ext_data):
         node, affiliation = result
 
         def append_item_config(items_data):
             ret = []
-            for item, access_model, access_list in items_data:
+            for item_data in items_data:
+                item, access_model, access_list = item_data.item, item_data.access_model, item_data.config
                 if access_model == const.VAL_AMODEL_OPEN:
                     pass
                 elif access_model == const.VAL_AMODEL_ROSTER:
@@ -631,10 +637,11 @@
 
             if itemIdentifiers:
                 d = node.getItemsById(authorized_groups, unrestricted, itemIdentifiers)
+                d.addCallback(self._tuple2ItemData)
             else:
-                d = node.getItems(authorized_groups, unrestricted, maxItems,
-                                  ext_data)
+                d = node.getItems(authorized_groups, unrestricted, maxItems, ext_data)
                 if unrestricted:
+                    d.addCallback(self._tuple2ItemData)
                     d.addCallback(append_item_config)
 
             for extension in ext_data:
@@ -765,6 +772,7 @@
             return d
 
         d = node.getItemsById(None, True, itemIdentifiers)
+        d.addCallback(self._tuple2ItemData)
         d.addCallback(removeItems)
 
         if notify:
@@ -1012,7 +1020,7 @@
                                            set([Subscription(node.nodeIdentifier,
                                                             owner_jid,
                                                             'subscribed')]),
-                                           [item for item, _, _ in items_data]))
+                                           [item_data.item for item_data in items_data]))
 
             if pep:
                 return self.backend.privilege.notifyRetract(