@@ -112,23 +112,28 @@ def value(self, value):
112
112
)
113
113
self ._value = value
114
114
115
+ def __is_subrecord (self , attr ):
116
+ return (hasattr (super (), '__dict__' )
117
+ and isinstance (super ().__dict__ .get ("_value" , None ), dict )
118
+ and attr in super ().value )
119
+
115
120
def __getattr__ (self , attr ):
116
- if isinstance ( getattr ( super (), "_value" , None ), dict ) and attr in super (). value :
121
+ if self . __is_subrecord ( attr ) :
117
122
return super ().value [attr ].value
118
123
raise AttributeError (f"'{ self .__class__ .__name__ } ' object has no attribute '{ attr } '" )
119
124
120
- def __setattr__ (self , name , value ):
121
- if isinstance ( getattr ( super (), "_value" , None ), dict ) and name in super (). value :
122
- self .value [name ].value = value
125
+ def __setattr__ (self , attr , value ):
126
+ if self . __is_subrecord ( attr ) :
127
+ self .value [attr ].value = value
123
128
else :
124
- super ().__setattr__ (name , value )
129
+ super ().__setattr__ (attr , value )
125
130
126
131
def _build_rec_dict (self , naming_map , appendTo ):
127
132
if isinstance (self .value , dict ):
128
133
for r in self .value .values ():
129
134
if r .value is not None : # NOTE: should filter by updated when it's supported.
130
135
r ._build_rec_dict (naming_map , appendTo )
131
- else :
136
+ elif self . _value is not None :
132
137
super ()._build_rec_dict (naming_map , appendTo )
133
138
134
139
def add_to_pack (self , pack ):
0 commit comments