)]}'
{"id":"openstack%2Foslo.versionedobjects~718345","triplet_id":"openstack%2Foslo.versionedobjects~master~I4ec039cf73cfd54e32b5a22dae391df7fafb9142","project":"openstack/oslo.versionedobjects","branch":"master","topic":"bug/1874482","hashtags":[],"change_id":"I4ec039cf73cfd54e32b5a22dae391df7fafb9142","subject":"Handle overriding of \u0027obj_class_from_primitive\u0027","status":"ABANDONED","created":"2020-04-08 08:41:23.000000000","updated":"2020-06-03 09:58:22.000000000","total_comment_count":75,"unresolved_comment_count":0,"has_review_started":true,"meta_rev_id":"ea50dc8a91f46542ab0a00e8c1b4bd900eafd790","_number":718345,"virtual_id_number":718345,"owner":{"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},"actions":{},"labels":{"Verified":{"recommended":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"all":[{"date":"2020-04-24 08:35:36.000000000","_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},{"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},{"tag":"autogenerated:zuul:check","value":1,"date":"2020-04-23 18:03:12.000000000","permitted_voting_range":{"min":-2,"max":2},"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]}],"values":{"-2":"Fails","-1":"Doesn\u0027t seem to work"," 0":"No score","+1":"Works for me","+2":"Verified"},"description":"","value":1,"default_value":0,"optional":true},"Code-Review":{"rejected":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"all":[{"value":0,"permitted_voting_range":{"min":-1,"max":1},"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},{"value":0,"permitted_voting_range":{"min":-2,"max":2},"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},{"value":-2,"date":"2020-04-23 18:10:25.000000000","permitted_voting_range":{"min":-2,"max":2},"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},{"value":0,"permitted_voting_range":{"min":-2,"max":2},"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},{"value":0,"permitted_voting_range":{"min":-1,"max":1},"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]}],"values":{"-2":"Do not merge","-1":"This patch needs further work before it can be merged"," 0":"No score","+1":"Looks good to me, but someone else must approve","+2":"Looks good to me (core reviewer)"},"description":"","default_value":0,"optional":true},"Workflow":{"all":[{"value":0,"permitted_voting_range":{"min":-1,"max":0},"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},{"value":0,"permitted_voting_range":{"min":-1,"max":1},"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},{"value":0,"permitted_voting_range":{"min":-1,"max":1},"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},{"value":0,"permitted_voting_range":{"min":-1,"max":1},"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]}],"values":{"-1":"Work in progress"," 0":"Ready for reviews","+1":"Approved"},"description":"","default_value":0,"optional":true},"Backport-Candidate":{"all":[{"value":0,"permitted_voting_range":{"min":-1,"max":1},"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},{"value":0,"permitted_voting_range":{"min":-2,"max":2},"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},{"value":0,"permitted_voting_range":{"min":-2,"max":2},"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},{"value":0,"permitted_voting_range":{"min":-2,"max":2},"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},{"value":0,"permitted_voting_range":{"min":-1,"max":1},"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]}],"values":{"-2":"Do Not Backport","-1":"Not A Backport Candidate"," 0":"Backport Review Needed","+1":"Proposed Backport","+2":"Should Backport"},"description":"","default_value":0,"optional":true}},"removable_reviewers":[],"reviewers":{"REVIEWER":[{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},{"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},{"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"}]},"pending_reviewers":{},"reviewer_updates":[{"updated":"2020-04-16 11:53:03.000000000","updated_by":{"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},"reviewer":{"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},"state":"REVIEWER"},{"updated":"2020-04-23 16:25:30.000000000","updated_by":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"reviewer":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"state":"REVIEWER"},{"updated":"2020-04-23 18:03:12.000000000","updated_by":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"reviewer":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"state":"REVIEWER"},{"updated":"2020-04-23 18:10:25.000000000","updated_by":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"reviewer":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"state":"REVIEWER"}],"messages":[{"id":"3ebc5143b3aa2f66a7026bc5efbf63a4390cc767","author":{"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},"date":"2020-04-08 08:41:23.000000000","message":"Uploaded patch set 1.","accounts_in_message":[],"_revision_number":1},{"id":"c88cd7e8b7dbbcae21d621799204f2b84eb38fed","tag":"autogenerated:zuul:check","author":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"date":"2020-04-08 10:15:35.000000000","message":"Patch Set 1: Verified+1\n\n(64 comments)\n\nBuild succeeded (check pipeline).\n\n- tempest-full-py3 https://zuul.opendev.org/t/openstack/build/8da29bfd034540309f7e4d87a5531d45 : SUCCESS in 1h 14m 34s\n- openstack-tox-lower-constraints https://zuul.opendev.org/t/openstack/build/f672f1c2f62a458994ad1e2bd91421ba : SUCCESS in 5m 09s\n- openstack-tox-pep8 https://zuul.opendev.org/t/openstack/build/bb1f1343e96f48ef8e04e1cd93bce4bd : SUCCESS in 6m 12s\n- openstack-tox-py36 https://zuul.opendev.org/t/openstack/build/a1d62537c16d4847818b97a6bf837532 : SUCCESS in 6m 24s\n- openstack-tox-py37 https://zuul.opendev.org/t/openstack/build/93eee861146746d2932fc3b59d57b7ff : SUCCESS in 7m 42s\n- openstack-tox-py38 https://zuul.opendev.org/t/openstack/build/6b1c59ab9cf342dbbe20fbdc826b46fe : SUCCESS in 6m 33s (non-voting)\n- openstack-tox-docs https://zuul.opendev.org/t/openstack/build/4a47a0c0fa664e338549d78862876166 : SUCCESS in 5m 21s\n- oslo.versionedobjects-src-grenade-devstack-multinode https://zuul.opendev.org/t/openstack/build/04d5e0d2e50847fab4f02867a3a9aedd : FAILURE in 26m 18s (non-voting)\n\nWarning:\n  Comments left for invalid file oslo_versionedobjects/tests/test_fixture.py","accounts_in_message":[],"_revision_number":1},{"id":"3cebd92c86ab9e35654ac9ad14357812941563e4","author":{"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},"date":"2020-04-16 11:53:03.000000000","message":"Patch Set 1:\n\n(3 comments)\n\nHello,\n\nSome inline suggests and concerns","accounts_in_message":[],"_revision_number":1},{"id":"719a9c9aaa35f81f6edcaa7e9838698b9a10a5cf","author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"date":"2020-04-23 16:25:30.000000000","message":"Uploaded patch set 2.","accounts_in_message":[],"_revision_number":2},{"id":"3efa588ad15245898a746a41f07be726a9042f21","author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"date":"2020-04-23 16:27:05.000000000","message":"Topic changed from from_field_primitive to bug/1874482","accounts_in_message":[],"_revision_number":2},{"id":"87e824da48c73570cd74b0a059a81c486eedc84d","author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"date":"2020-04-23 16:27:24.000000000","message":"Patch Set 3: Commit message was updated.","accounts_in_message":[],"_revision_number":3},{"id":"78d7f613fcd56ee8a5f3d932cacfe18145398b51","author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"date":"2020-04-23 16:29:29.000000000","message":"Patch Set 1:\n\n(2 comments)","accounts_in_message":[],"_revision_number":1},{"id":"1917c3c36ea6292c09ad43573e3a0441ee027784","tag":"autogenerated:zuul:check","author":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"date":"2020-04-23 18:03:12.000000000","message":"Patch Set 3: Verified+1\n\nBuild succeeded (check pipeline).\n\n- tempest-full-py3 https://zuul.opendev.org/t/openstack/build/c2afb1feafd24637860f9e9b075073de : SUCCESS in 1h 29m 54s\n- openstack-tox-lower-constraints https://zuul.opendev.org/t/openstack/build/aac00b6c98564d698806b3c9a723507a : SUCCESS in 4m 46s\n- openstack-tox-pep8 https://zuul.opendev.org/t/openstack/build/fdddbcd10a83426cbffc38f09a5fe7b8 : SUCCESS in 6m 38s\n- openstack-tox-py36 https://zuul.opendev.org/t/openstack/build/2faf0441a65d41d6bcc5aa3722234bd5 : SUCCESS in 5m 44s\n- openstack-tox-py38 https://zuul.opendev.org/t/openstack/build/e68acb472d8f4b0291a559c51d16df2f : SUCCESS in 6m 44s\n- openstack-tox-docs https://zuul.opendev.org/t/openstack/build/d0b6eea0d78f4f0a891fd6590439bc0a : SUCCESS in 6m 17s\n- oslo.versionedobjects-src-grenade-devstack-multinode https://zuul.opendev.org/t/openstack/build/ac4abd388b154bedb05a5ed011b08fa4 : FAILURE in 22m 41s (non-voting)","accounts_in_message":[],"_revision_number":3},{"id":"91948da8ea97072aefe98a744cccda11f7c2bfbc","author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"date":"2020-04-23 18:10:25.000000000","message":"Patch Set 3: Code-Review-2\n\n(1 comment)","accounts_in_message":[],"_revision_number":3},{"id":"d2fc1e375a8d1f067558c7cfebc4f578ca1cd5ab","author":{"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},"date":"2020-04-24 06:54:38.000000000","message":"Patch Set 3:\n\n(3 comments)","accounts_in_message":[],"_revision_number":3},{"id":"074aa132e57e978f0863151bdc401e7a7499bcd4","author":{"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},"date":"2020-04-24 07:38:45.000000000","message":"Patch Set 1:\n\n(2 comments)","accounts_in_message":[],"_revision_number":1},{"id":"4fb4fe580defbb25080888004706af133f9728a6","author":{"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},"date":"2020-04-24 08:35:36.000000000","message":"Patch Set 3:\n\nThen, the versioned object represeting a same target in different nodes might be attached with different version, since there might have some nodes in newer nova-xx service version and some in older version in same cluster. It offers the new-to-old version converting method in \"obj_make_compatible\" method. Likely, we might need a function, such as \"obj_make_compatible_from_version\", to offer the role of transforming an old version object to this, a bumped version one. \n\nDan Smith wrote:\n\n\u003e (1 comment)","accounts_in_message":[],"_revision_number":3},{"id":"ea50dc8a91f46542ab0a00e8c1b4bd900eafd790","author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"date":"2020-06-03 09:58:22.000000000","message":"Abandoned","accounts_in_message":[],"_revision_number":3}],"current_revision_number":3,"current_revision":"709dc003d3d6f6ba5e0fa591a67841132a5af54a","revisions":{"7b99f28b1fd45b3ef9b839e3fcef908f13a0e111":{"kind":"REWORK","_number":1,"created":"2020-04-08 08:41:23.000000000","uploader":{"_account_id":30209,"name":"Huaqiang","email":"huaqiang.wang@intel.com","username":"Huaqiang.Wang"},"ref":"refs/changes/45/718345/1","fetch":{"anonymous http":{"url":"https://review.opendev.org/openstack/oslo.versionedobjects","ref":"refs/changes/45/718345/1","commands":{"Checkout":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/1 \u0026\u0026 git checkout FETCH_HEAD","Cherry Pick":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/1 \u0026\u0026 git cherry-pick FETCH_HEAD","Format Patch":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/1 \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD","Pull":"git pull https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/1"}}},"commit":{"parents":[{"commit":"4d2310b2a96358405ee4c855bd707937be165e50","subject":"Use unittest.mock instead of third party mock","web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/4d2310b2a96358405ee4c855bd707937be165e50"}]}],"author":{"name":"Wang Huaqiang","email":"huaqiang.wang@intel.com","date":"2020-04-08 08:17:18.000000000","tz":480},"committer":{"name":"Wang Huaqiang","email":"huaqiang.wang@intel.com","date":"2020-04-08 08:41:10.000000000","tz":480},"subject":"call the field object\u0027s \u0027obj_from_primitive\u0027 instead of calling object","message":"call the field object\u0027s \u0027obj_from_primitive\u0027 instead of calling object\n\nGiven a class inherited from `VersionedObject` and having another\n`VersionedObject` attached as its fields object,  with the type\nof `ObjectField`, if this class overrides the base class\u0027s\n`obj_from_primitive` method, it will find that the @primitve\nparameter of this subclass function will not always be the subclass\u0027s\nprimitive dictionary.\n\nWhile we\u0027d better to assume that the @primitive object passed\n to `obj_from_primitive` is the primitive of the object itself.\n We can achieve this by invoking the \u0027obj_from_primitive\u0027 method\nfor the field object from the field class.\n\nChange-Id: I4ec039cf73cfd54e32b5a22dae391df7fafb9142\n","web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/7b99f28b1fd45b3ef9b839e3fcef908f13a0e111"}],"resolve_conflicts_web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/7b99f28b1fd45b3ef9b839e3fcef908f13a0e111"}]},"branch":"refs/heads/master"},"c885401113770214da5a02ee35db5a252e834a6c":{"kind":"REWORK","_number":2,"created":"2020-04-23 16:25:30.000000000","uploader":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"ref":"refs/changes/45/718345/2","fetch":{"anonymous http":{"url":"https://review.opendev.org/openstack/oslo.versionedobjects","ref":"refs/changes/45/718345/2","commands":{"Checkout":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/2 \u0026\u0026 git checkout FETCH_HEAD","Cherry Pick":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/2 \u0026\u0026 git cherry-pick FETCH_HEAD","Format Patch":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/2 \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD","Pull":"git pull https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/2"}}},"commit":{"parents":[{"commit":"b59f459d361ce933cf5465516f641ac8f6f4b0c3","subject":"trivial: Mock warnings","web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/b59f459d361ce933cf5465516f641ac8f6f4b0c3"}]}],"author":{"name":"Wang Huaqiang","email":"huaqiang.wang@intel.com","date":"2020-04-08 08:17:18.000000000","tz":480},"committer":{"name":"Stephen Finucane","email":"stephenfin@redhat.com","date":"2020-04-23 16:24:48.000000000","tz":60},"subject":"Handle overriding of \u0027obj_class_from_primitive\u0027","message":"Handle overriding of \u0027obj_class_from_primitive\u0027\n\nConsider the following object hierarchy:\n\n  Foo\n    id (IntegerField)\n\n  Bar\n    id (IntegerField)\n    foo (ObjectField(Foo))\n\nOne can serialize the \u0027Bar\u0027 object by calling the \u0027obj_to_primitive\u0027\nmethod of a \u0027Bar\u0027 instance, which will call \u0027to_primitive\u0027 for each\nfield on the object. In the case of the \u0027foo\u0027 field, because it\u0027s an\n\u0027ObjectField\u0027, this will in turn call a \u0027obj_to_primitive\u0027 method again,\nonly this time the one from \u0027Foo\u0027, leading to additional calls to\nvarious \u0027to_primitive\u0027 functions and, if necessary, additional\n\u0027obj_to_primitive\u0027 calls.\n\nThings should work quite similarly for deserialization. One can\ndeserialize a serialized \u0027Bar\u0027 instance by calling the\n\u0027obj_from_primitive\u0027 class method of \u0027Bar\u0027, which will call\n\u0027from_primitive\u0027 for each field. Once again, \u0027ObjectField\u0027 instances\nresult in additional calls to a \u0027obj_from_primitive\u0027 class method.\nHowever, here things diverge. While serialization will result in a call\nto the \u0027obj_to_primitive\u0027 method of the object in the field, or the\n\"child\" object, deserialization results in a call to the\n\u0027obj_from_primitive\u0027 class method of the \"parent\" object. This means\nobjects that override the \u0027obj_from_primitive\u0027 method will not see the\ncorrect overriden behavior when the object is embedded in another\nobject.\n\nThe solution is simple. The \u0027obj_from_primitive\u0027 class method is split\ninto two: the existing \u0027obj_from_primitive\u0027 class method and a new\n\u0027obj_class_from_primitive\u0027 method, which does the lookup of the child\nobject within the same namespace as the parent object. The expectation\nis that users can continue to override the latter, while the former\nshould remain untouched.\n\nChange-Id: I4ec039cf73cfd54e32b5a22dae391df7fafb9142\nCo-authored-by: Stephen Finucane \u003cstephen@that.guru\u003e\n","web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/c885401113770214da5a02ee35db5a252e834a6c"}],"resolve_conflicts_web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/c885401113770214da5a02ee35db5a252e834a6c"}]},"branch":"refs/heads/master"},"709dc003d3d6f6ba5e0fa591a67841132a5af54a":{"kind":"NO_CODE_CHANGE","_number":3,"created":"2020-04-23 16:27:24.000000000","uploader":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"ref":"refs/changes/45/718345/3","fetch":{"anonymous http":{"url":"https://review.opendev.org/openstack/oslo.versionedobjects","ref":"refs/changes/45/718345/3","commands":{"Checkout":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/3 \u0026\u0026 git checkout FETCH_HEAD","Cherry Pick":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/3 \u0026\u0026 git cherry-pick FETCH_HEAD","Format Patch":"git fetch https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/3 \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD","Pull":"git pull https://review.opendev.org/openstack/oslo.versionedobjects refs/changes/45/718345/3"}}},"commit":{"parents":[{"commit":"b59f459d361ce933cf5465516f641ac8f6f4b0c3","subject":"trivial: Mock warnings","web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/b59f459d361ce933cf5465516f641ac8f6f4b0c3"}]}],"author":{"name":"Wang Huaqiang","email":"huaqiang.wang@intel.com","date":"2020-04-08 08:17:18.000000000","tz":480},"committer":{"name":"Stephen Finucane","email":"stephenfin@redhat.com","date":"2020-04-23 16:27:22.000000000","tz":0},"subject":"Handle overriding of \u0027obj_class_from_primitive\u0027","message":"Handle overriding of \u0027obj_class_from_primitive\u0027\n\nConsider the following object hierarchy:\n\n  Foo\n    id (IntegerField)\n\n  Bar\n    id (IntegerField)\n    foo (ObjectField(Foo))\n\nOne can serialize the \u0027Bar\u0027 object by calling the \u0027obj_to_primitive\u0027\nmethod of a \u0027Bar\u0027 instance, which will call \u0027to_primitive\u0027 for each\nfield on the object. In the case of the \u0027foo\u0027 field, because it\u0027s an\n\u0027ObjectField\u0027, this will in turn call a \u0027obj_to_primitive\u0027 method again,\nonly this time the one from \u0027Foo\u0027, leading to additional calls to\nvarious \u0027to_primitive\u0027 functions and, if necessary, additional\n\u0027obj_to_primitive\u0027 calls.\n\nThings should work quite similarly for deserialization. One can\ndeserialize a serialized \u0027Bar\u0027 instance by calling the\n\u0027obj_from_primitive\u0027 class method of \u0027Bar\u0027, which will call\n\u0027from_primitive\u0027 for each field. Once again, \u0027ObjectField\u0027 instances\nresult in additional calls to a \u0027obj_from_primitive\u0027 class method.\nHowever, here things diverge. While serialization will result in a call\nto the \u0027obj_to_primitive\u0027 method of the object in the field, or the\n\"child\" object, deserialization results in a call to the\n\u0027obj_from_primitive\u0027 class method of the \"parent\" object. This means\nobjects that override the \u0027obj_from_primitive\u0027 method will not see the\ncorrect overriden behavior when the object is embedded in another\nobject.\n\nThe solution is simple. The \u0027obj_from_primitive\u0027 class method is split\ninto two: the existing \u0027obj_from_primitive\u0027 class method and a new\n\u0027obj_class_from_primitive\u0027 method, which does the lookup of the child\nobject within the same namespace as the parent object. The expectation\nis that users can continue to override the latter, while the former\nshould remain untouched.\n\nChange-Id: I4ec039cf73cfd54e32b5a22dae391df7fafb9142\nCo-authored-by: Stephen Finucane \u003cstephen@that.guru\u003e\nCloses-Bug: #1874482\n","web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/709dc003d3d6f6ba5e0fa591a67841132a5af54a"}],"resolve_conflicts_web_links":[{"name":"gitea","tooltip":"Open in GitWeb","url":"https://opendev.org/openstack/oslo.versionedobjects/commit/709dc003d3d6f6ba5e0fa591a67841132a5af54a"}]},"branch":"refs/heads/master"}},"requirements":[],"submit_records":[],"submit_requirements":[]}
