MongoEngine/mongoengine — pull request #457 by gitaarik (2013-09-02 16:18:15+00:00)
Title: Check if undefined fields are supplied on document

If an undefined field is supplied to a document instance, a `FieldDoesNotExist` Exception will be raised. This way, you will be notified when you provide a field that does not exist.

ATM when you do this:

MyDoc(undefined_field="test")

It will create a document instance for `MyDoc`. However, if `undefined_field` does not exist, the value `test` won't end up anywhere. You'll think the object is successfully created with the provided values, but actually it isn't.

To remedy this situation, an exception will be raised. This way you'll be noticed about your mistake in development. If the document instance is created dynamically on bases of an API call data for example, then you can catch the exeption and notify the API user that they have provided an undefined field.