'obj_from_primitive' of embedded objects is not used

Bug #1874482 reported by Stephen Finucane
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.versionedobjects
Won't Fix
Medium
Stephen Finucane

Bug Description

Consider the following objects:

 @obj_base.VersionedObjectRegistry.register
 class Bar(obj_base.VersionedObject):
     fields = {
         'id': fields.IntegerField(),
         'name': fields.StringField(),
     }

     @classmethod
     def obj_from_primitive(cls, primitive, context=None):
         # do something...
         return super().obj_from_primitive(primitive, context)

 @obj_base.VersionedObjectRegistry.register
 class Foo(obj_base.VersionedObject):
     fields = {
         'name': fields.StringField(),
         'bar': fields.ObjectField('Bar'),
     }

If you deserialize and reserialize an instance of 'Foo', you'll note the 'obj_from_primitive' method from the 'Bar' object is never called. Things work correctly when working with 'Bar' directly. This appears to be because we are always calling the parents 'obj_from_primitive' function when deserializing child objects [1].

[1] https://github.com/openstack/oslo.versionedobjects/blob/2.0.2/oslo_versionedobjects/fields.py#L823

Changed in oslo.versionedobjects:
assignee: nobody → Stephen Finucane (stephenfinucane)
status: New → In Progress
Changed in oslo.versionedobjects:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on oslo.versionedobjects (master)

Change abandoned by Stephen Finucane (<email address hidden>) on branch: master
Review: https://review.opendev.org/718345

Revision history for this message
Stephen Finucane (stephenfinucane) wrote :

After discussion on the fix, it appears we should not be overriding this function and so this behaviour is expected.

Changed in oslo.versionedobjects:
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.