Use for loop instead of map to modify iterables
Previously we use map() to apply changes to every item in a iterable object, but this is not a proper usage. And in Python3, map() will return a map iterator object, changes will not be applied immediately, as we're not iterating the map object, changes will never be applied. Changing to for loop instead fixes. Partial-Bug: #1755413 Change-Id: Iebbfaca67cda72300636e51686bac3b1513b127d Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
This commit is contained in:
parent
996e134a1c
commit
e5f00207f7
@ -86,7 +86,8 @@ class IndexView(horizon_tables.DataTableView):
|
|||||||
msg = _('Unable to retrieve database clusters.')
|
msg = _('Unable to retrieve database clusters.')
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
|
|
||||||
map(self._extra_data, clusters)
|
for cluster in clusters:
|
||||||
|
self._extra_data(cluster)
|
||||||
|
|
||||||
return clusters
|
return clusters
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ class DatabaseTab(tabs.TableTab):
|
|||||||
instance = self.tab_group.kwargs['instance']
|
instance = self.tab_group.kwargs['instance']
|
||||||
try:
|
try:
|
||||||
data = api.trove.database_list(self.request, instance.id)
|
data = api.trove.database_list(self.request, instance.id)
|
||||||
add_instance = lambda d: setattr(d, 'instance', instance)
|
for database in data:
|
||||||
map(add_instance, data)
|
setattr(database, 'instance', instance)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = _('Unable to get databases data.')
|
msg = _('Unable to get databases data.')
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
|
@ -80,7 +80,8 @@ class IndexView(horizon_tables.DataTableView):
|
|||||||
instances = []
|
instances = []
|
||||||
msg = _('Unable to retrieve database instances.')
|
msg = _('Unable to retrieve database instances.')
|
||||||
exceptions.handle(self.request, msg)
|
exceptions.handle(self.request, msg)
|
||||||
map(self._extra_data, instances)
|
for instance in instances:
|
||||||
|
self._extra_data(instance)
|
||||||
return instances
|
return instances
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user