)]}'
{"glance/api/policy.py":[{"author":{"_account_id":6159,"name":"Flavio Percoco Premoli","display_name":"flaper87","email":"flavio.percoco@flyrlabs.com","username":"flaper87"},"change_message_id":"e80ec33f0c205c99fbc945c189760376ef2cdc5a","unresolved":false,"context_lines":[{"line_number":214,"context_line":"        new_locations \u003d list(value)"},{"line_number":215,"context_line":"        for location in self.image.locations:"},{"line_number":216,"context_line":"            if location not in new_locations:"},{"line_number":217,"context_line":"                self.policy.enforce(self.context, \u0027delete_image_location\u0027, {})"},{"line_number":218,"context_line":"                break"},{"line_number":219,"context_line":"        self.image.locations \u003d new_locations"},{"line_number":220,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAP3%2F%2Fprc%3D","line":217,"updated":"2013-07-15 09:52:01.000000000","message":"We could move this outside the loop and enforce it just once, there\u0027s no need to enforce delete_image_location for each location.\n\nWhat about:\n\n  \u003e\u003e\u003e new_locs \u003d set([1,2,3,4])\n  \u003e\u003e\u003e old_locs \u003d set([3,4,5,6])\n  \u003e\u003e\u003e to_remove \u003d old_locs - new_locs\n  \u003e\u003e\u003e to_remove\n  set([5, 6])\n\nYou can then do:\n\n  if to_remove:\n      self.policy.enforce(self.context, \u0027delete_image_location\u0027, {})","commit_id":"9210b82872676e32d0aa974c22b7c6f5fba9b117"},{"author":{"_account_id":6549,"name":"Zhi Yan Liu","email":"lzy.dev@gmail.com","username":"lzy-dev"},"change_message_id":"e79883a25091366ede7a3281fcd15a8a1404ed57","unresolved":false,"context_lines":[{"line_number":214,"context_line":"        new_locations \u003d list(value)"},{"line_number":215,"context_line":"        for location in self.image.locations:"},{"line_number":216,"context_line":"            if location not in new_locations:"},{"line_number":217,"context_line":"                self.policy.enforce(self.context, \u0027delete_image_location\u0027, {})"},{"line_number":218,"context_line":"                break"},{"line_number":219,"context_line":"        self.image.locations \u003d new_locations"},{"line_number":220,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAP3%2F%2FpOY%3D","line":217,"in_reply_to":"AAAAP3%2F%2FpWc%3D","updated":"2013-07-15 13:23:44.000000000","message":"I\u0027d like use \"set([loc[\u0027url\u0027] for loc in self.image.locations])\" to allow this way go. thanks.","commit_id":"9210b82872676e32d0aa974c22b7c6f5fba9b117"},{"author":{"_account_id":6159,"name":"Flavio Percoco Premoli","display_name":"flaper87","email":"flavio.percoco@flyrlabs.com","username":"flaper87"},"change_message_id":"7d22a149d65b3c841159946c09a8a7afa264f065","unresolved":false,"context_lines":[{"line_number":214,"context_line":"        new_locations \u003d list(value)"},{"line_number":215,"context_line":"        for location in self.image.locations:"},{"line_number":216,"context_line":"            if location not in new_locations:"},{"line_number":217,"context_line":"                self.policy.enforce(self.context, \u0027delete_image_location\u0027, {})"},{"line_number":218,"context_line":"                break"},{"line_number":219,"context_line":"        self.image.locations \u003d new_locations"},{"line_number":220,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAP3%2F%2FpWc%3D","line":217,"in_reply_to":"AAAAP3%2F%2FphU%3D","updated":"2013-07-15 12:48:23.000000000","message":"Ops, didn\u0027t know it was a dict. You can do it with self.image.locations.keys()","commit_id":"9210b82872676e32d0aa974c22b7c6f5fba9b117"},{"author":{"_account_id":6549,"name":"Zhi Yan Liu","email":"lzy.dev@gmail.com","username":"lzy-dev"},"change_message_id":"21b3213c16dc2687afbb78091067901ae633cd97","unresolved":false,"context_lines":[{"line_number":214,"context_line":"        new_locations \u003d list(value)"},{"line_number":215,"context_line":"        for location in self.image.locations:"},{"line_number":216,"context_line":"            if location not in new_locations:"},{"line_number":217,"context_line":"                self.policy.enforce(self.context, \u0027delete_image_location\u0027, {})"},{"line_number":218,"context_line":"                break"},{"line_number":219,"context_line":"        self.image.locations \u003d new_locations"},{"line_number":220,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAP3%2F%2Fpjo%3D","line":217,"in_reply_to":"AAAAP3%2F%2Fprc%3D","updated":"2013-07-15 11:06:39.000000000","message":"Good idea, will use this way in next PS.","commit_id":"9210b82872676e32d0aa974c22b7c6f5fba9b117"},{"author":{"_account_id":6549,"name":"Zhi Yan Liu","email":"lzy.dev@gmail.com","username":"lzy-dev"},"change_message_id":"061e88e7ea3e6915856523c315bcff8ce3e432df","unresolved":false,"context_lines":[{"line_number":214,"context_line":"        new_locations \u003d list(value)"},{"line_number":215,"context_line":"        for location in self.image.locations:"},{"line_number":216,"context_line":"            if location not in new_locations:"},{"line_number":217,"context_line":"                self.policy.enforce(self.context, \u0027delete_image_location\u0027, {})"},{"line_number":218,"context_line":"                break"},{"line_number":219,"context_line":"        self.image.locations \u003d new_locations"},{"line_number":220,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAP3%2F%2FphU%3D","line":217,"in_reply_to":"AAAAP3%2F%2Fprc%3D","updated":"2013-07-15 11:57:39.000000000","message":"Oops, we can not do this, since currectly location is a directory object, \u0027set([{}])\u0027 will be failed by \"TypeError: unhashable type: \u0027dict\u0027\" exception.","commit_id":"9210b82872676e32d0aa974c22b7c6f5fba9b117"}],"glance/tests/unit/v2/test_images_resource.py":[{"author":{"_account_id":4463,"name":"iccha-sethi","email":"iccha.sethi@rackspace.com","username":"iccha-sethi"},"change_message_id":"89a2a93b534c0f655b5285e8843b85a6285a4d0c","unresolved":false,"context_lines":[{"line_number":979,"context_line":"                          request, UUID1, changes)"},{"line_number":980,"context_line":""},{"line_number":981,"context_line":"    def test_update_set_image_location_unauthorized(self):"},{"line_number":982,"context_line":"        rules \u003d {\"get_image_location\": False}"},{"line_number":983,"context_line":"        self.policy.set_rules(rules)"},{"line_number":984,"context_line":"        new_location \u003d \u0027%s/fake_location\u0027 % BASE_URI"},{"line_number":985,"context_line":"        request \u003d unit_test_utils.get_fake_request()"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAP3%2F%2Fq6U%3D","line":982,"updated":"2013-07-14 12:35:22.000000000","message":"did u mean set_image_location here?","commit_id":"f636700bab34732b9b3f89fe2e7ca8fdc1dd05e7"},{"author":{"_account_id":6549,"name":"Zhi Yan Liu","email":"lzy.dev@gmail.com","username":"lzy-dev"},"change_message_id":"28a8b3b324882f3ff62d6d223a57a376e9b0d28d","unresolved":false,"context_lines":[{"line_number":979,"context_line":"                          request, UUID1, changes)"},{"line_number":980,"context_line":""},{"line_number":981,"context_line":"    def test_update_set_image_location_unauthorized(self):"},{"line_number":982,"context_line":"        rules \u003d {\"get_image_location\": False}"},{"line_number":983,"context_line":"        self.policy.set_rules(rules)"},{"line_number":984,"context_line":"        new_location \u003d \u0027%s/fake_location\u0027 % BASE_URI"},{"line_number":985,"context_line":"        request \u003d unit_test_utils.get_fake_request()"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAP3%2F%2Fq3g%3D","line":982,"in_reply_to":"AAAAP3%2F%2Fq6U%3D","updated":"2013-07-14 15:26:36.000000000","message":"Good catch, will fix this in next PS.","commit_id":"f636700bab34732b9b3f89fe2e7ca8fdc1dd05e7"},{"author":{"_account_id":4463,"name":"iccha-sethi","email":"iccha.sethi@rackspace.com","username":"iccha-sethi"},"change_message_id":"89a2a93b534c0f655b5285e8843b85a6285a4d0c","unresolved":false,"context_lines":[{"line_number":986,"context_line":"        changes \u003d [{\u0027op\u0027: \u0027add\u0027, \u0027path\u0027: [\u0027locations\u0027, \u0027-\u0027],"},{"line_number":987,"context_line":"                    \u0027value\u0027: new_location}]"},{"line_number":988,"context_line":"        self.assertRaises(webob.exc.HTTPForbidden, self.controller.update,"},{"line_number":989,"context_line":"                          request, UUID1, changes)"},{"line_number":990,"context_line":""},{"line_number":991,"context_line":"    def test_update_delete_image_location_unauthorized(self):"},{"line_number":992,"context_line":"        rules \u003d {\"delete_image_location\": False}"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAP3%2F%2Fq6Q%3D","line":989,"updated":"2013-07-14 12:35:22.000000000","message":"this test and the test above look same to me :) maybe I am missing out something. could you please point out the difference to me?","commit_id":"f636700bab34732b9b3f89fe2e7ca8fdc1dd05e7"},{"author":{"_account_id":6549,"name":"Zhi Yan Liu","email":"lzy.dev@gmail.com","username":"lzy-dev"},"change_message_id":"28a8b3b324882f3ff62d6d223a57a376e9b0d28d","unresolved":false,"context_lines":[{"line_number":986,"context_line":"        changes \u003d [{\u0027op\u0027: \u0027add\u0027, \u0027path\u0027: [\u0027locations\u0027, \u0027-\u0027],"},{"line_number":987,"context_line":"                    \u0027value\u0027: new_location}]"},{"line_number":988,"context_line":"        self.assertRaises(webob.exc.HTTPForbidden, self.controller.update,"},{"line_number":989,"context_line":"                          request, UUID1, changes)"},{"line_number":990,"context_line":""},{"line_number":991,"context_line":"    def test_update_delete_image_location_unauthorized(self):"},{"line_number":992,"context_line":"        rules \u003d {\"delete_image_location\": False}"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAP3%2F%2Fq3U%3D","line":989,"in_reply_to":"AAAAP3%2F%2Fq6Q%3D","updated":"2013-07-14 15:26:36.000000000","message":"Yes, I forget update this test case after I separate it out from #35134. Actually if you check https://review.openstack.org/#/c/35134/4/glance/api/v2/images.py Line #168, you can see \u0027add\u0027 location PATCH handler can touch \u0027set_image_location\u0027 checking logic. I will fix this in next PS.","commit_id":"f636700bab34732b9b3f89fe2e7ca8fdc1dd05e7"},{"author":{"_account_id":4463,"name":"iccha-sethi","email":"iccha.sethi@rackspace.com","username":"iccha-sethi"},"change_message_id":"a00aac8108179d007fe41aa1f828c18ac8a30ce8","unresolved":false,"context_lines":[{"line_number":972,"context_line":"        rules \u003d {\"get_image_location\": False}"},{"line_number":973,"context_line":"        self.policy.set_rules(rules)"},{"line_number":974,"context_line":"        request \u003d unit_test_utils.get_fake_request()"},{"line_number":975,"context_line":"        changes \u003d [{\u0027op\u0027: \u0027replace\u0027, \u0027path\u0027: [\u0027locations\u0027], \u0027value\u0027: []}]"},{"line_number":976,"context_line":"        self.assertRaises(webob.exc.HTTPForbidden, self.controller.update,"},{"line_number":977,"context_line":"                          request, UUID1, changes)"},{"line_number":978,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAP3%2F%2Fq0k%3D","line":975,"updated":"2013-07-14 16:18:31.000000000","message":"you are replacing stuff here, how is the rule get_image_locations then ? :) sorry trying to understand","commit_id":"9210b82872676e32d0aa974c22b7c6f5fba9b117"},{"author":{"_account_id":6549,"name":"Zhi Yan Liu","email":"lzy.dev@gmail.com","username":"lzy-dev"},"change_message_id":"4820b26f0e8a485effd0d5d3cc1e25091a460247","unresolved":false,"context_lines":[{"line_number":972,"context_line":"        rules \u003d {\"get_image_location\": False}"},{"line_number":973,"context_line":"        self.policy.set_rules(rules)"},{"line_number":974,"context_line":"        request \u003d unit_test_utils.get_fake_request()"},{"line_number":975,"context_line":"        changes \u003d [{\u0027op\u0027: \u0027replace\u0027, \u0027path\u0027: [\u0027locations\u0027], \u0027value\u0027: []}]"},{"line_number":976,"context_line":"        self.assertRaises(webob.exc.HTTPForbidden, self.controller.update,"},{"line_number":977,"context_line":"                          request, UUID1, changes)"},{"line_number":978,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAP3%2F%2Fqac%3D","line":975,"in_reply_to":"AAAAP3%2F%2Fq0k%3D","updated":"2013-07-15 02:00:55.000000000","message":"https://github.com/openstack/glance/blob/master/glance/api/v2/images.py#L197 will trigger \u0027get_image_locatio\u0027 policy checking.","commit_id":"9210b82872676e32d0aa974c22b7c6f5fba9b117"}]}
