Mercurial > libervia-pubsub
diff sat_pubsub/pgsql_storage.py @ 356:95c83899b5e9
pgsql: fixed bad data filling in getItemsData:
item_id was wrongly used to fill ItemData container. Attribute names instead of index are now used to avoid this in the future.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 08 Sep 2017 08:02:05 +0200 |
parents | efbdca10f0fb |
children | 1167e48e5f52 |
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py Fri Sep 08 08:02:05 2017 +0200 +++ b/sat_pubsub/pgsql_storage.py Fri Sep 08 08:02:05 2017 +0200 @@ -964,24 +964,24 @@ if unrestricted and not ids_only: # with unrestricted query, we need to fill the access_list for a roster access items ret = [] - for data in result: - item = generic.stripNamespace(parseXml(data[0])) - access_model = data[1] - item_id = data[2] - date = data[3] + for item_data in result: + item = generic.stripNamespace(parseXml(item_data.data)) + access_model = item_data.access_model + item_id = item_data.item_id + date = item_data.date access_list = {} if access_model == const.VAL_AMODEL_PUBLISHER_ROSTER: cursor.execute('SELECT groupname FROM item_groups_authorized WHERE item_id=%s', (item_id,)) - access_list[const.OPT_ROSTER_GROUPS_ALLOWED] = [r[0] for r in cursor.fetchall()] + access_list[const.OPT_ROSTER_GROUPS_ALLOWED] = [r.groupname for r in cursor.fetchall()] ret.append(container.ItemData(item, access_model, access_list, date=date)) # TODO: whitelist item access model return ret if ids_only: - return [r[0] for r in result] + return [r.item for r in result] else: - items_data = [container.ItemData(generic.stripNamespace(parseXml(r[0])), r[1], r[2], date=r[3]) for r in result] + items_data = [container.ItemData(generic.stripNamespace(parseXml(r.data)), r.access_model, date=r.date) for r in result] return items_data def getItemsById(self, authorized_groups, unrestricted, itemIdentifiers):