)]}'
{"openstack_dashboard/dashboards/project/instances/workflows/create_instance.py":[{"author":{"_account_id":841,"name":"Akihiro Motoki","email":"amotoki@gmail.com","username":"amotoki"},"change_message_id":"7fd723a82ed1e03526feeb2b6947a219110cc27c","unresolved":false,"context_lines":[{"line_number":272,"context_line":"            flavors \u003d api.nova.flavor_list(request)"},{"line_number":273,"context_line":"            flavor_sort \u003d getattr(settings, \u0027CREATE_INSTANCE_FLAVOR_SORT\u0027, {})"},{"line_number":274,"context_line":"            rev \u003d flavor_sort.get(\u0027reverse\u0027, False)"},{"line_number":275,"context_line":"            key \u003d flavor_sort.get(\u0027key\u0027, lambda flavor: flavor.ram)"},{"line_number":276,"context_line":""},{"line_number":277,"context_line":"            flavor_list \u003d [(flavor.id, \"%s\" % flavor.name)"},{"line_number":278,"context_line":"                           for flavor in sorted(flavors, key\u003dkey, reverse\u003drev)]"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAP3%2F%2F6lc%3D","line":275,"updated":"2013-07-09 09:19:02.000000000","message":"I would like to avoid lambda method in local_settings if possible.\n\nPython 2.5 or later, we have operator.attrgetter() and we can sort with multiple fields by using attrgetter().\n\nkeys \u003d [\u0027ram\u0027, \u0027name\u0027]\nsorted(flavors, key\u003doperator.attrgetter(*keys), reverse\u003drev)\n\nIf so, we have a list of sort keys in local_settings:\n\nCREATE_INSTNACE_FLAVOR_SORT \u003d {\n  \u0027keys\u0027: [\u0027ram\u0027, \u0027name\u0027],\n  \u0027reverse\u0027: True,\n}\n\nNote that one limitation of this method is that we cannot specify the sort order key by key. To support a sort order per key, we need to define a sort method.","commit_id":"c36cf392e8053aebac05f9372a6504e2515d24a7"}]}
