From d7ded366c77cc15acb0e54b14a270b780a5462ea Mon Sep 17 00:00:00 2001 From: Stefan Wojcik Date: Mon, 17 Jun 2019 14:34:13 +0200 Subject: [PATCH] Document params expected by BaseDocument.__init__ [ci skip] --- mongoengine/base/document.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index e3283141..cebcf337 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -45,13 +45,20 @@ class BaseDocument(object): def __init__(self, *args, **values): """ - Initialise a document or embedded document + Initialise a document or an embedded document. - :param __auto_convert: Try and will cast python objects to Object types - :param values: A dictionary of values for the document + :param values: A dictionary of keys and values for the document. + It may contain additional reserved keywords, e.g. "__auto_convert". + :param __auto_convert: If True, supplied values will be converted + to Python-type values via each field's `to_python` method. + :param __only_fields: A list of fields that have been loaded for this + document. Empty if all fields have been loaded. + :param _created: Indicates whether this is a brand new document or + whether it's already been persisted before. Defaults to true. """ self._initialised = False self._created = True + if args: # Combine positional arguments with named arguments. # We only want named arguments. @@ -135,6 +142,7 @@ class BaseDocument(object): # Flag initialised self._initialised = True self._created = _created + signals.post_init.send(self.__class__, document=self) def __delattr__(self, *args, **kwargs):