You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class A(JsonObject):
field1 = StringProperty(required=True)
class B(JsonObject):
a = ObjectProperty(A, default=None)
Then when I create an instance of B like b = B(), I will get an error:
Traceback (most recent call last):
File "/Users/keith/molabs/movideo/tests/commons/api/views/test_mapper.py", line 160, in test_required
b = B()
File "/Users/keith/molabs/movideo/lib/jsonobject/base.py", line 229, in __init__
d = value.default()
File "/Users/keith/molabs/movideo/lib/jsonobject/properties.py", line 128, in <lambda>
default = lambda self: self.item_type()
File "/Users/keith/molabs/movideo/lib/jsonobject/base.py", line 232, in __init__
self[key] = d
File "/Users/keith/molabs/movideo/lib/jsonobject/base.py", line 296, in __setitem__
wrapped, unwrapped = self.__unwrap(key, value)
File "/Users/keith/molabs/movideo/lib/jsonobject/base.py", line 283, in __unwrap
recursive=False,
File "/Users/keith/molabs/movideo/lib/jsonobject/base_properties.py", line 113, in validate
'Property {0} is required.'.format(self.name)
BadValueError: Property field1 is required.
If I set the default of the item to be None, it seems to work. Why shouldn't an object just have a default of None?
The text was updated successfully, but these errors were encountered:
If I have something like this:
Then when I create an instance of B like
b = B()
, I will get an error:If I set the default of the item to be None, it seems to work. Why shouldn't an object just have a default of None?
The text was updated successfully, but these errors were encountered: