)]}'
{"oslo_context/context.py":[{"author":{"_account_id":9459,"name":".Haifeng Yan","email":"yanheven@qq.com","username":"yan"},"change_message_id":"a0aaaf3bc8376c719d51384c318e0eb90d90026a","unresolved":false,"context_lines":[{"line_number":170,"context_line":"    def from_dict(cls, values):"},{"line_number":171,"context_line":"        \"\"\"Construct a context object from a provided dictionary.\"\"\""},{"line_number":172,"context_line":"        allowed \u003d [arg for arg in"},{"line_number":173,"context_line":"                   inspect.getargspec(RequestContext.__init__).args"},{"line_number":174,"context_line":"                   if arg !\u003d \u0027self\u0027]"},{"line_number":175,"context_line":"        kwargs \u003d {k: v for (k, v) in values.items() if k in allowed}"},{"line_number":176,"context_line":"        return cls(**kwargs)"}],"source_content_type":"text/x-python","patch_set":1,"id":"dada55a8_484be559","side":"PARENT","line":173,"range":{"start_line":173,"start_character":38,"end_line":173,"end_character":52},"updated":"2016-07-23 08:18:38.000000000","message":"I have an idea, replace RequestContext with cls, will get args of subclass   instead of RequestContext.","commit_id":"9feb9db8d667bc5bc9ca43e2073227c1e8e44bbb"},{"author":{"_account_id":7191,"name":"Jamie Lennox","email":"jamielennox@gmail.com","username":"jamielennox"},"change_message_id":"744318082671779de4ca38d931aa102a1d153cfb","unresolved":false,"context_lines":[{"line_number":170,"context_line":"    def from_dict(cls, values):"},{"line_number":171,"context_line":"        \"\"\"Construct a context object from a provided dictionary.\"\"\""},{"line_number":172,"context_line":"        allowed \u003d [arg for arg in"},{"line_number":173,"context_line":"                   inspect.getargspec(RequestContext.__init__).args"},{"line_number":174,"context_line":"                   if arg !\u003d \u0027self\u0027]"},{"line_number":175,"context_line":"        kwargs \u003d {k: v for (k, v) in values.items() if k in allowed}"},{"line_number":176,"context_line":"        return cls(**kwargs)"}],"source_content_type":"text/x-python","patch_set":1,"id":"bacf61ea_b7889672","side":"PARENT","line":173,"range":{"start_line":173,"start_character":38,"end_line":173,"end_character":52},"in_reply_to":"dada55a8_484be559","updated":"2016-07-30 18:41:13.000000000","message":"yes, but that only works if all the subclass parameters are listed with the exact same name as the arguments to __init__. Most projects i am pushing to pass unknown **kwargs to RequestContext.__init__ and so this wouldn\u0027t work there.\n\nYou could work the class hierarchy and guess at all this but i would much prefer to make it explicit.","commit_id":"9feb9db8d667bc5bc9ca43e2073227c1e8e44bbb"},{"author":{"_account_id":16051,"name":"Ronald Bradford","email":"ronald.bradford@gmail.com","username":"ronaldbradford"},"change_message_id":"aed51932443c537afb2f15c072c7736937034259","unresolved":false,"context_lines":[{"line_number":178,"context_line":"        kwargs.setdefault(\u0027read_only\u0027, values.get(\u0027read_only\u0027, False))"},{"line_number":179,"context_line":"        kwargs.setdefault(\u0027show_deleted\u0027, values.get(\u0027show_deleted\u0027, False))"},{"line_number":180,"context_line":"        kwargs.setdefault(\u0027request_id\u0027, values.get(\u0027request_id\u0027))"},{"line_number":181,"context_line":"        kwargs.setdefault(\u0027resource_uuid\u0027, values.get(\u0027resource_uuid\u0027))"},{"line_number":182,"context_line":"        kwargs.setdefault(\u0027roles\u0027, values.get(\u0027roles\u0027))"},{"line_number":183,"context_line":"        kwargs.setdefault(\u0027user_name\u0027, values.get(\u0027user_name\u0027))"},{"line_number":184,"context_line":"        kwargs.setdefault(\u0027project_name\u0027, values.get(\u0027project_name\u0027))"}],"source_content_type":"text/x-python","patch_set":1,"id":"1aa78d24_a634174a","line":181,"updated":"2016-07-15 14:01:20.000000000","message":"you do not have overwrite here, but you also don\u0027t need it based on the purpose of the class method.  May warrant a comment later to indicate why this list does not match __init__ args","commit_id":"3a118faa83d807de3469e35236569a48261b34de"},{"author":{"_account_id":7191,"name":"Jamie Lennox","email":"jamielennox@gmail.com","username":"jamielennox"},"change_message_id":"10d68b8c7eaac010e53972eeb6fb63c034964f0c","unresolved":false,"context_lines":[{"line_number":178,"context_line":"        kwargs.setdefault(\u0027read_only\u0027, values.get(\u0027read_only\u0027, False))"},{"line_number":179,"context_line":"        kwargs.setdefault(\u0027show_deleted\u0027, values.get(\u0027show_deleted\u0027, False))"},{"line_number":180,"context_line":"        kwargs.setdefault(\u0027request_id\u0027, values.get(\u0027request_id\u0027))"},{"line_number":181,"context_line":"        kwargs.setdefault(\u0027resource_uuid\u0027, values.get(\u0027resource_uuid\u0027))"},{"line_number":182,"context_line":"        kwargs.setdefault(\u0027roles\u0027, values.get(\u0027roles\u0027))"},{"line_number":183,"context_line":"        kwargs.setdefault(\u0027user_name\u0027, values.get(\u0027user_name\u0027))"},{"line_number":184,"context_line":"        kwargs.setdefault(\u0027project_name\u0027, values.get(\u0027project_name\u0027))"}],"source_content_type":"text/x-python","patch_set":1,"id":"dada55a8_dab59a31","line":181,"in_reply_to":"1aa78d24_a634174a","updated":"2016-07-19 23:56:27.000000000","message":"a comment was probably a good idea, but passing overwrite through to_dict/from_dict seems like a bad idea as it controls behaviour rather than is data.","commit_id":"3a118faa83d807de3469e35236569a48261b34de"},{"author":{"_account_id":2218,"name":"Adam Young","email":"adam@younglogic.com","username":"ayoung"},"change_message_id":"915544ce484bbfc95a24d9d7ffbc270c8a91c2e8","unresolved":false,"context_lines":[{"line_number":178,"context_line":"        kwargs.setdefault(\u0027read_only\u0027, values.get(\u0027read_only\u0027, False))"},{"line_number":179,"context_line":"        kwargs.setdefault(\u0027show_deleted\u0027, values.get(\u0027show_deleted\u0027, False))"},{"line_number":180,"context_line":"        kwargs.setdefault(\u0027request_id\u0027, values.get(\u0027request_id\u0027))"},{"line_number":181,"context_line":"        kwargs.setdefault(\u0027resource_uuid\u0027, values.get(\u0027resource_uuid\u0027))"},{"line_number":182,"context_line":"        kwargs.setdefault(\u0027roles\u0027, values.get(\u0027roles\u0027))"},{"line_number":183,"context_line":"        kwargs.setdefault(\u0027user_name\u0027, values.get(\u0027user_name\u0027))"},{"line_number":184,"context_line":"        kwargs.setdefault(\u0027project_name\u0027, values.get(\u0027project_name\u0027))"}],"source_content_type":"text/x-python","patch_set":1,"id":"9ad45d7e_8106f71a","line":181,"in_reply_to":"dada55a8_dab59a31","updated":"2016-08-10 17:55:45.000000000","message":"Agreed.  Leave it this way.","commit_id":"3a118faa83d807de3469e35236569a48261b34de"}],"oslo_context/tests/test_context.py":[{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"df4b46daa832cdc7f815cfb6d45e4edbb9193881","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            \"color\": \"red\","},{"line_number":147,"context_line":"            \"unknown\": \"\""},{"line_number":148,"context_line":"        }"},{"line_number":149,"context_line":"        ctx \u003d context.RequestContext.from_dict(dct,"},{"line_number":150,"context_line":"                                               user\u003d\"user2\","},{"line_number":151,"context_line":"                                               project_name\u003d\"project1\")"},{"line_number":152,"context_line":"        self.assertEqual(\"token1\", ctx.auth_token)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9ad45d7e_6257f7ca","line":149,"updated":"2016-08-12 20:14:33.000000000","message":"Is this a pattern that comes up in real use? Why aren\u0027t user and project_name just part of dct already when from_dict() is being called?","commit_id":"3a118faa83d807de3469e35236569a48261b34de"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"94ed851148054ea7b7f2d6091f6bc878030319cd","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            \"color\": \"red\","},{"line_number":147,"context_line":"            \"unknown\": \"\""},{"line_number":148,"context_line":"        }"},{"line_number":149,"context_line":"        ctx \u003d context.RequestContext.from_dict(dct,"},{"line_number":150,"context_line":"                                               user\u003d\"user2\","},{"line_number":151,"context_line":"                                               project_name\u003d\"project1\")"},{"line_number":152,"context_line":"        self.assertEqual(\"token1\", ctx.auth_token)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3ac371cc_70dde713","line":149,"in_reply_to":"3ac371cc_1afe826b","updated":"2016-08-15 21:02:42.000000000","message":"So a subclass is going to define its own from_dict(), and take as input the environment dictionary and pass to the base class here that dict and some overrides? I guess that\u0027s instead of having the subclass just modify the dictionary it passes to the base class?","commit_id":"3a118faa83d807de3469e35236569a48261b34de"},{"author":{"_account_id":7191,"name":"Jamie Lennox","email":"jamielennox@gmail.com","username":"jamielennox"},"change_message_id":"6c93c1776dca5bf712c44095e9404d5004c917ee","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            \"color\": \"red\","},{"line_number":147,"context_line":"            \"unknown\": \"\""},{"line_number":148,"context_line":"        }"},{"line_number":149,"context_line":"        ctx \u003d context.RequestContext.from_dict(dct,"},{"line_number":150,"context_line":"                                               user\u003d\"user2\","},{"line_number":151,"context_line":"                                               project_name\u003d\"project1\")"},{"line_number":152,"context_line":"        self.assertEqual(\"token1\", ctx.auth_token)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3ac371cc_976c9636","line":149,"in_reply_to":"3ac371cc_70dde713","updated":"2016-08-16 23:38:18.000000000","message":"So yea, it gives that and it also lets you add additional things to the kwargs that get passed to your subclass\u0027s __init__.","commit_id":"3a118faa83d807de3469e35236569a48261b34de"},{"author":{"_account_id":7191,"name":"Jamie Lennox","email":"jamielennox@gmail.com","username":"jamielennox"},"change_message_id":"ae730a5582b4a92328f9442f4734f79dc6e3fc17","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            \"color\": \"red\","},{"line_number":147,"context_line":"            \"unknown\": \"\""},{"line_number":148,"context_line":"        }"},{"line_number":149,"context_line":"        ctx \u003d context.RequestContext.from_dict(dct,"},{"line_number":150,"context_line":"                                               user\u003d\"user2\","},{"line_number":151,"context_line":"                                               project_name\u003d\"project1\")"},{"line_number":152,"context_line":"        self.assertEqual(\"token1\", ctx.auth_token)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3ac371cc_d7e0ce98","line":149,"in_reply_to":"3ac371cc_976c9636","updated":"2016-08-16 23:40:49.000000000","message":"this is basically the same pattern I used in from_context and most of the loader stuff in keystoneauth and varioius clients.","commit_id":"3a118faa83d807de3469e35236569a48261b34de"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"a6c99f0e573ed84802fc9d18246c54d0003a57dc","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            \"color\": \"red\","},{"line_number":147,"context_line":"            \"unknown\": \"\""},{"line_number":148,"context_line":"        }"},{"line_number":149,"context_line":"        ctx \u003d context.RequestContext.from_dict(dct,"},{"line_number":150,"context_line":"                                               user\u003d\"user2\","},{"line_number":151,"context_line":"                                               project_name\u003d\"project1\")"},{"line_number":152,"context_line":"        self.assertEqual(\"token1\", ctx.auth_token)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3ac371cc_7fb70c3a","line":149,"in_reply_to":"3ac371cc_d7e0ce98","updated":"2016-08-17 16:12:02.000000000","message":"OK, it just seemed odd to have the API say \"here\u0027s a dictionary with named arguments and you can also pass the same names as keyword args to override what you\u0027re putting in the dictionary\" but if the caller doesn\u0027t own the dict and we don\u0027t want them to use from_dict(**environ) or whatever then I guess I can see this working.","commit_id":"3a118faa83d807de3469e35236569a48261b34de"},{"author":{"_account_id":7191,"name":"Jamie Lennox","email":"jamielennox@gmail.com","username":"jamielennox"},"change_message_id":"6197a52f44456503e529375afbf56257ead54cf1","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            \"color\": \"red\","},{"line_number":147,"context_line":"            \"unknown\": \"\""},{"line_number":148,"context_line":"        }"},{"line_number":149,"context_line":"        ctx \u003d context.RequestContext.from_dict(dct,"},{"line_number":150,"context_line":"                                               user\u003d\"user2\","},{"line_number":151,"context_line":"                                               project_name\u003d\"project1\")"},{"line_number":152,"context_line":"        self.assertEqual(\"token1\", ctx.auth_token)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3ac371cc_1afe826b","line":149,"in_reply_to":"9ad45d7e_6257f7ca","updated":"2016-08-15 00:30:10.000000000","message":"It\u0027s a pattern that will allow subclasses to set a value in preference to what\u0027s in the dictionary. For example heat will set user_id in the dict, not user and so we would need to overwrite the default value. Nova and others also do strange things with the dictionary that we need a way to override the default behaviour.","commit_id":"3a118faa83d807de3469e35236569a48261b34de"}]}
