The behavior of empty model instances is unexpected IMO. When you create a new model instance without any properties set, it evaluates to False in boolean expression. For example the following code snippet raises an assertion error either if some_id is None or some_id = 'DOES_NOT_EXIST':
if some_id is None:
obj = MyModel() # create a new instance
else:
obj = MyModel.collection.find_one({'_id': ObjectId(some_id)}) # retrieve from datastore
assert obj
I would have expected that only the second path raises an assertion error.
The behavior of empty model instances is unexpected IMO. When you create a new model instance without any properties set, it evaluates to False in boolean expression. For example the following code snippet raises an assertion error either if some_id is None or some_id = 'DOES_NOT_EXIST':
if some_id is None:
obj = MyModel() # create a new instance
else:
obj = MyModel.collection.find_one({'_id': ObjectId(some_id)}) # retrieve from datastore
assert obj
I would have expected that only the second path raises an assertion error.