)]}'
{"openstack/resource.py":[{"author":{"_account_id":1669,"name":"Julien Danjou","display_name":"jd","email":"julien@danjou.info","username":"jdanjou"},"change_message_id":"10a370853439aa0ae735b46daf2bc21cee1c506f","unresolved":false,"context_lines":[{"line_number":791,"context_line":"        if count \u003e 1:"},{"line_number":792,"context_line":"            msg \u003d \"More than one %s exists with the name \u0027%s\u0027.\""},{"line_number":793,"context_line":"            msg \u003d (msg % (cls.get_resource_name(), name_or_id))"},{"line_number":794,"context_line":"            raise exceptions.DuplicateResource(msg)"},{"line_number":795,"context_line":""},{"line_number":796,"context_line":"        return result[0] if count \u003d\u003d 1 else None"}],"source_content_type":"text/x-python","patch_set":2,"id":"da86d52c_50991d78","line":794,"updated":"2015-02-16 13:45:23.000000000","message":"I know this is not related to that change, but I wonder why you raise a DuplicateResource here. You could just return the list of result, and let the application decide if it\u0027s a problem to have more than one resource for that \"find\".\n\nSome APIs might return several resources with the same name for example.","commit_id":"b3e84ff38c9125d76ebe2c48ef5aaceae1a9fb38"},{"author":{"_account_id":8257,"name":"Brian Curtin","email":"brian@python.org","username":"briancurtin"},"change_message_id":"4eee8da3155fb563eeab127e82347d830d5c41f0","unresolved":false,"context_lines":[{"line_number":791,"context_line":"        if count \u003e 1:"},{"line_number":792,"context_line":"            msg \u003d \"More than one %s exists with the name \u0027%s\u0027.\""},{"line_number":793,"context_line":"            msg \u003d (msg % (cls.get_resource_name(), name_or_id))"},{"line_number":794,"context_line":"            raise exceptions.DuplicateResource(msg)"},{"line_number":795,"context_line":""},{"line_number":796,"context_line":"        return result[0] if count \u003d\u003d 1 else None"}],"source_content_type":"text/x-python","patch_set":2,"id":"da86d52c_3fa391b2","line":794,"in_reply_to":"da86d52c_1f732db5","updated":"2015-02-16 15:58:01.000000000","message":"When we have more user guide stuff we can always show off how to find multiple matches, do some filtering, or solve other find related things beyond finding one name/id.","commit_id":"b3e84ff38c9125d76ebe2c48ef5aaceae1a9fb38"},{"author":{"_account_id":8257,"name":"Brian Curtin","email":"brian@python.org","username":"briancurtin"},"change_message_id":"11a69d38564920ba931d2eb2bec8ec4c5bac0c77","unresolved":false,"context_lines":[{"line_number":791,"context_line":"        if count \u003e 1:"},{"line_number":792,"context_line":"            msg \u003d \"More than one %s exists with the name \u0027%s\u0027.\""},{"line_number":793,"context_line":"            msg \u003d (msg % (cls.get_resource_name(), name_or_id))"},{"line_number":794,"context_line":"            raise exceptions.DuplicateResource(msg)"},{"line_number":795,"context_line":""},{"line_number":796,"context_line":"        return result[0] if count \u003d\u003d 1 else None"}],"source_content_type":"text/x-python","patch_set":2,"id":"da86d52c_e9a78809","line":794,"in_reply_to":"da86d52c_50991d78","updated":"2015-02-16 14:47:39.000000000","message":"Terry - what do you think about this? What if we make this return whatever it finds from filter and push it off to subclasses to be more specific, either in paring down the results of this find or of implementing their own complete override?\n\nI get the sense that the common case is that resources are generally named uniquely, and this being a base class should work toward the common case of finding one result. While you could name all of your servers the same, users are likely going to name them differently and then want to look for one of them. I think the same goes for looking for flavors and images while writing a quick script - you\u0027ll want to pass in \"high-performance\" and \"ubuntu 12.10\" and just get back one thing you can send into compute.create_server.\n\nI currently have a tool that spins up a lot of servers where they are prefixed on some term, so in my own code I would have my own method that filters on a partial match, but I don\u0027t think we should get into stuff like that.","commit_id":"b3e84ff38c9125d76ebe2c48ef5aaceae1a9fb38"},{"author":{"_account_id":8736,"name":"Terry Howe","email":"terrylhowe@gmail.com","username":"terrylhowe"},"change_message_id":"51402ab073b031000d1d165e6d4dffc7a0b1bc9d","unresolved":false,"context_lines":[{"line_number":791,"context_line":"        if count \u003e 1:"},{"line_number":792,"context_line":"            msg \u003d \"More than one %s exists with the name \u0027%s\u0027.\""},{"line_number":793,"context_line":"            msg \u003d (msg % (cls.get_resource_name(), name_or_id))"},{"line_number":794,"context_line":"            raise exceptions.DuplicateResource(msg)"},{"line_number":795,"context_line":""},{"line_number":796,"context_line":"        return result[0] if count \u003d\u003d 1 else None"}],"source_content_type":"text/x-python","patch_set":2,"id":"da86d52c_1f732db5","line":794,"in_reply_to":"da86d52c_e9a78809","updated":"2015-02-16 15:52:21.000000000","message":"Well, this find thing was something I got out of OSC and in that use case you want just one resource.  In OSC, every command supports name or id to identify a resource.  I always figured if a user wanted all the matches, you would use list.","commit_id":"b3e84ff38c9125d76ebe2c48ef5aaceae1a9fb38"},{"author":{"_account_id":8736,"name":"Terry Howe","email":"terrylhowe@gmail.com","username":"terrylhowe"},"change_message_id":"fd0eef604474594f9572713680423da220255743","unresolved":false,"context_lines":[{"line_number":792,"context_line":"            match \u003d any([from_id \u003d\u003d name_or_id, from_name \u003d\u003d name_or_id])"},{"line_number":793,"context_line":"            return resource if match else None"},{"line_number":794,"context_line":""},{"line_number":795,"context_line":"        result \u003d list(filter(search, cls.list(session, path_args\u003dpath_args)))"},{"line_number":796,"context_line":""},{"line_number":797,"context_line":"        count \u003d len(result)"},{"line_number":798,"context_line":"        if count \u003e 1:"}],"source_content_type":"text/x-python","patch_set":3,"id":"da86d52c_fa6f1efa","line":795,"updated":"2015-02-17 16:41:49.000000000","message":"This is way less efficient on large lists because we are getting all the results and searching them client side rather than trusting server side.  The client probably has spare cycles to burn for the search, but we are wasting the clients time making it return all the data.\n\nIf anything, the id find should skip the page call and use a get_by_id() and we\u0027d just need to look for resources that don\u0027t support that.","commit_id":"6f6db69d290d16a2274672f21b661c02b134c51b"},{"author":{"_account_id":8736,"name":"Terry Howe","email":"terrylhowe@gmail.com","username":"terrylhowe"},"change_message_id":"9080e4de6fc37ad05b64d10126e4007ca39600f6","unresolved":false,"context_lines":[{"line_number":792,"context_line":"            match \u003d any([from_id \u003d\u003d name_or_id, from_name \u003d\u003d name_or_id])"},{"line_number":793,"context_line":"            return resource if match else None"},{"line_number":794,"context_line":""},{"line_number":795,"context_line":"        result \u003d list(filter(search, cls.list(session, path_args\u003dpath_args)))"},{"line_number":796,"context_line":""},{"line_number":797,"context_line":"        count \u003d len(result)"},{"line_number":798,"context_line":"        if count \u003e 1:"}],"source_content_type":"text/x-python","patch_set":3,"id":"da86d52c_1d4a2c27","line":795,"in_reply_to":"da86d52c_fa6f1efa","updated":"2015-02-17 16:49:09.000000000","message":"What if this change was put in a search method that that could be used kind of in the allow_page\u003dFalse type situation?","commit_id":"6f6db69d290d16a2274672f21b661c02b134c51b"}]}
