From 6618270b687a872ab5347c242430605686885899 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Sat, 22 Dec 2012 06:26:05 +0800 Subject: [PATCH] Fixes inefficiency in quantum.api.v2.base._filters Use iteritems() instead of getall() on request.GET Fixes bug #1092995 Change-Id: Ic0b5e3d7c7b1ddd072d9fe918ea22a8e9aef9ee4 --- quantum/api/v2/base.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/quantum/api/v2/base.py b/quantum/api/v2/base.py index 77eae90c61..b2a7b185e6 100644 --- a/quantum/api/v2/base.py +++ b/quantum/api/v2/base.py @@ -63,28 +63,17 @@ def _filters(request, attr_info): {'check': [u'a', u'b'], 'name': [u'Bob']} """ res = {} - for key in set(request.GET): + for key, values in request.GET.dict_of_lists().iteritems(): if key == 'fields': continue - values = [v for v in request.GET.getall(key) if v] - if not values: - continue - key_attr_info = attr_info.get(key) - if not key_attr_info: - res[key] = values - continue - convert_list_to = key_attr_info.get('convert_list_to') - if not convert_list_to: - convert_to = key_attr_info.get('convert_to') - if convert_to: - convert_list_to = lambda values_: [convert_to(x) - for x in values_] - else: - convert_list_to = lambda values_: None - result_values = convert_list_to(values) - if result_values: - res[key] = result_values - else: + values = [v for v in values if v] + key_attr_info = attr_info.get(key, {}) + if 'convert_list_to' in key_attr_info: + values = key_attr_info['convert_list_to'](values) + elif 'convert_to' in key_attr_info: + convert_to = key_attr_info['convert_to'] + values = [convert_to(v) for v in values] + if values: res[key] = values return res