)]}'
{"nova/context.py":[{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"83da054769143a333d7ea483fa961e53ef57525f","unresolved":false,"context_lines":[{"line_number":302,"context_line":"    # NOTE(alaski): This method should only be used when an admin context is"},{"line_number":303,"context_line":"    # necessary for the entirety of the context lifetime. If that\u0027s not the"},{"line_number":304,"context_line":"    # case please use get_context(), or create the RequestContext manually, and"},{"line_number":305,"context_line":"    # use context.elevated() where necessary."},{"line_number":306,"context_line":"    return RequestContext(user_id\u003dNone,"},{"line_number":307,"context_line":"                          project_id\u003dNone,"},{"line_number":308,"context_line":"                          is_admin\u003dTrue,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_cf3a8dcd","line":305,"updated":"2016-09-28 23:40:21.000000000","message":"It might also be worth noting that any anonymous RequestContext (example: periodic tasks) that wants to read from the db probably needs get_admin_context(), otherwise the query will be filtered on project_id and yield nothing.","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"},{"author":{"_account_id":5441,"name":"Andrew Laski","email":"andrew@lascii.com","username":"alaski"},"change_message_id":"2a20fa5ccd49b5f21833dc0f131d8566a26f6649","unresolved":false,"context_lines":[{"line_number":302,"context_line":"    # NOTE(alaski): This method should only be used when an admin context is"},{"line_number":303,"context_line":"    # necessary for the entirety of the context lifetime. If that\u0027s not the"},{"line_number":304,"context_line":"    # case please use get_context(), or create the RequestContext manually, and"},{"line_number":305,"context_line":"    # use context.elevated() where necessary."},{"line_number":306,"context_line":"    return RequestContext(user_id\u003dNone,"},{"line_number":307,"context_line":"                          project_id\u003dNone,"},{"line_number":308,"context_line":"                          is_admin\u003dTrue,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_ad8c3880","line":305,"in_reply_to":"3a98d1f4_804ae4aa","updated":"2016-09-29 17:26:38.000000000","message":"Yeah. It was a while back now but I remember a time when we had to untangle what actually needed an admin context and what did not. I just mostly want to avoid getting there again by being very clear where admin is needed vs not.","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"cd727c2c45a160e7377bf5f024399f46aaf18765","unresolved":false,"context_lines":[{"line_number":302,"context_line":"    # NOTE(alaski): This method should only be used when an admin context is"},{"line_number":303,"context_line":"    # necessary for the entirety of the context lifetime. If that\u0027s not the"},{"line_number":304,"context_line":"    # case please use get_context(), or create the RequestContext manually, and"},{"line_number":305,"context_line":"    # use context.elevated() where necessary."},{"line_number":306,"context_line":"    return RequestContext(user_id\u003dNone,"},{"line_number":307,"context_line":"                          project_id\u003dNone,"},{"line_number":308,"context_line":"                          is_admin\u003dTrue,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_804ae4aa","line":305,"in_reply_to":"3a98d1f4_a84a7bc3","updated":"2016-09-29 16:59:40.000000000","message":"Oh, so you\u0027re thinking the periodic task would be kicked off in the beginning with get_context() and then inside the periodic task method, use .elevated() at the beginning before doing queries? If so, I hadn\u0027t thought of that and the aforementioned note isn\u0027t needed.","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"},{"author":{"_account_id":5441,"name":"Andrew Laski","email":"andrew@lascii.com","username":"alaski"},"change_message_id":"49266432e2f50d1147a8c40050a4c75b8aacdc52","unresolved":false,"context_lines":[{"line_number":302,"context_line":"    # NOTE(alaski): This method should only be used when an admin context is"},{"line_number":303,"context_line":"    # necessary for the entirety of the context lifetime. If that\u0027s not the"},{"line_number":304,"context_line":"    # case please use get_context(), or create the RequestContext manually, and"},{"line_number":305,"context_line":"    # use context.elevated() where necessary."},{"line_number":306,"context_line":"    return RequestContext(user_id\u003dNone,"},{"line_number":307,"context_line":"                          project_id\u003dNone,"},{"line_number":308,"context_line":"                          is_admin\u003dTrue,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_a84a7bc3","line":305,"in_reply_to":"3a98d1f4_cf3a8dcd","updated":"2016-09-29 12:52:39.000000000","message":"Okay, I\u0027ll add a note for that. I would eventually like to see that cleaned up and .elevated() used for those queries, but that\u0027s a later effort so for now the note will be good.","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"00ee03a79b4f29fe26cd2f6bef6254d5e84f525a","unresolved":false,"context_lines":[{"line_number":291,"context_line":""},{"line_number":292,"context_line":"    Note that overwrite is False here so this context will not update the"},{"line_number":293,"context_line":"    greenthread-local stored context that is used when logging."},{"line_number":294,"context_line":"    \"\"\""},{"line_number":295,"context_line":"    return RequestContext(user_id\u003dNone,"},{"line_number":296,"context_line":"                          project_id\u003dNone,"},{"line_number":297,"context_line":"                          is_admin\u003dFalse,"}],"source_content_type":"text/x-python","patch_set":2,"id":"3a98d1f4_9e7227ac","line":294,"updated":"2016-09-30 07:16:37.000000000","message":"May I ask when we will use this helper? People use admin context due to the db calls have limits on the normal user. When people needn\u0027t admin context, it means there isn\u0027t any limit in the db also, so the normal user\u0027s context is enough.","commit_id":"5fe5185443052980ae31231f572efb17fcce050a"},{"author":{"_account_id":5441,"name":"Andrew Laski","email":"andrew@lascii.com","username":"alaski"},"change_message_id":"e6faee332f93ae9b8198c1151e4be5d793fc648a","unresolved":false,"context_lines":[{"line_number":291,"context_line":""},{"line_number":292,"context_line":"    Note that overwrite is False here so this context will not update the"},{"line_number":293,"context_line":"    greenthread-local stored context that is used when logging."},{"line_number":294,"context_line":"    \"\"\""},{"line_number":295,"context_line":"    return RequestContext(user_id\u003dNone,"},{"line_number":296,"context_line":"                          project_id\u003dNone,"},{"line_number":297,"context_line":"                          is_admin\u003dFalse,"}],"source_content_type":"text/x-python","patch_set":2,"id":"3a98d1f4_a7b341e8","line":294,"in_reply_to":"3a98d1f4_9e7227ac","updated":"2016-09-30 13:28:46.000000000","message":"What I see happen a lot in tests is that someone needs a context so they use get_admin_context because it\u0027s the easiest way to get one. With this the goal is that in tests people will use get_context unless admin is necessary. But also in non test code, it\u0027s rare that someone needs to create a context but when they do they should not create an admin one unless necessary.\n\nAnd even if an admin context is needed it\u0027s usually better to create a user context and then context.elevate() where admin is needed.\n\nBut a big part of the motivation for this is when people need to create a context in a test.","commit_id":"5fe5185443052980ae31231f572efb17fcce050a"}],"nova/tests/unit/test_context.py":[{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"c729ccc164dcb02ec0ac22ab26a3ab69804d81be","unresolved":false,"context_lines":[{"line_number":147,"context_line":"        self.assertIs(o_context.get_current(), ctx1)"},{"line_number":148,"context_line":""},{"line_number":149,"context_line":"    def test_get_context_no_overwrite(self):"},{"line_number":150,"context_line":"        # If there is already a context in the cache creating an admin"},{"line_number":151,"context_line":"        # context will not overwrite it."},{"line_number":152,"context_line":"        ctx1 \u003d context.RequestContext(\u0027111\u0027,"},{"line_number":153,"context_line":"                                      \u0027222\u0027,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_74c14ce4","line":150,"range":{"start_line":150,"start_character":63,"end_line":150,"end_character":70},"updated":"2016-09-28 23:32:52.000000000","message":"Copy-paste error","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"},{"author":{"_account_id":5441,"name":"Andrew Laski","email":"andrew@lascii.com","username":"alaski"},"change_message_id":"49266432e2f50d1147a8c40050a4c75b8aacdc52","unresolved":false,"context_lines":[{"line_number":147,"context_line":"        self.assertIs(o_context.get_current(), ctx1)"},{"line_number":148,"context_line":""},{"line_number":149,"context_line":"    def test_get_context_no_overwrite(self):"},{"line_number":150,"context_line":"        # If there is already a context in the cache creating an admin"},{"line_number":151,"context_line":"        # context will not overwrite it."},{"line_number":152,"context_line":"        ctx1 \u003d context.RequestContext(\u0027111\u0027,"},{"line_number":153,"context_line":"                                      \u0027222\u0027,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_2884abd2","line":150,"range":{"start_line":150,"start_character":63,"end_line":150,"end_character":70},"in_reply_to":"3a98d1f4_74c14ce4","updated":"2016-09-29 12:52:39.000000000","message":"Woops","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"c729ccc164dcb02ec0ac22ab26a3ab69804d81be","unresolved":false,"context_lines":[{"line_number":153,"context_line":"                                      \u0027222\u0027,"},{"line_number":154,"context_line":"                                      overwrite\u003dTrue)"},{"line_number":155,"context_line":"        context.get_context()"},{"line_number":156,"context_line":"        self.assertIs(o_context.get_current(), ctx1)"},{"line_number":157,"context_line":""},{"line_number":158,"context_line":"    def test_admin_no_overwrite(self):"},{"line_number":159,"context_line":"        # If there is already a context in the cache creating an admin"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_b4bbd471","line":156,"range":{"start_line":156,"start_character":22,"end_line":156,"end_character":51},"updated":"2016-09-28 23:32:52.000000000","message":"I was going to say these should be swapped around but I see this is just copied from test_admin_no_overwrite.","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"},{"author":{"_account_id":5441,"name":"Andrew Laski","email":"andrew@lascii.com","username":"alaski"},"change_message_id":"49266432e2f50d1147a8c40050a4c75b8aacdc52","unresolved":false,"context_lines":[{"line_number":153,"context_line":"                                      \u0027222\u0027,"},{"line_number":154,"context_line":"                                      overwrite\u003dTrue)"},{"line_number":155,"context_line":"        context.get_context()"},{"line_number":156,"context_line":"        self.assertIs(o_context.get_current(), ctx1)"},{"line_number":157,"context_line":""},{"line_number":158,"context_line":"    def test_admin_no_overwrite(self):"},{"line_number":159,"context_line":"        # If there is already a context in the cache creating an admin"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a98d1f4_a8e6fbb1","line":156,"range":{"start_line":156,"start_character":22,"end_line":156,"end_character":51},"in_reply_to":"3a98d1f4_b4bbd471","updated":"2016-09-29 12:52:39.000000000","message":"Yeah, but since I\u0027m going to repush this I\u0027ll swap them.","commit_id":"a0bd1961f3895c60558c387ce7604e14f1f194b2"}]}
