The following code, when executed, runs validation on only two of the three fields upon save:
from modularodm import StoredObject, fields, storage
db = storage.EphemeralStorage()
def mock_validator(*args, **kwargs):
print("VALIDATING")
class BaseClass(StoredObject):
_meta = {
'abstract': True
}
pk = fields.IntegerField(primary=True, validate=mock_validator)
class MyMixin(StoredObject):
_meta = {
'abstract': True,
}
mixed_field = fields.IntegerField(validate=mock_validator)
class DerivedClass(BaseClass, MyMixin):
child_field = fields.IntegerField(validate=mock_validator)
BaseClass.set_storage(db)
DerivedClass.set_storage(db)
d = DerivedClass(
pk=1,
child_field=2,
mixed_field=3
)
d.save()
I've traced it down to line 800 of storedobject.py, before needing to move on to another task. The getattr call seems to be returning None for fields that were defined in the mixin.
The following code, when executed, runs validation on only two of the three fields upon save:
I've traced it down to line 800 of storedobject.py, before needing to move on to another task. The
getattrcall seems to be returningNonefor fields that were defined in the mixin.