Fixes Python 3 compatibility for filter results

Python 2.7 filter method result was a list, while for
Python 3.4 the result is a "filter object". Trying to
use it as a list will result in a TypeError.

Partial-Implements: blueprint porting-python3
Change-Id: I51836347f259d0223bcfa5cc2ec0b7fbd7a203eb
This commit is contained in:
Bo Wang 2016-01-13 13:58:37 +08:00
parent 4183c68480
commit 595788cbdc
2 changed files with 2 additions and 2 deletions

View File

@ -193,7 +193,7 @@ class TabGroup(html.HTMLElement):
return None
def get_loaded_tabs(self):
return filter(lambda t: self.get_tab(t.slug), self._tabs.values())
return [tab for tab in self._tabs.values() if self.get_tab(tab.slug)]
def get_selected_tab(self):
"""Returns the tab specific by the GET request parameter.

View File

@ -117,7 +117,7 @@ class GroupManageMixin(object):
domain=domain_id)
group_members = self._get_group_members()
group_member_ids = [user.id for user in group_members]
return filter(lambda u: u.id not in group_member_ids, all_users)
return [u for u in all_users if u.id not in group_member_ids]
class ManageMembersView(GroupManageMixin, tables.DataTableView):