From d37a30e0838e10e95457c63f8842a22362c04bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Sun, 30 Jun 2019 20:46:40 +0200 Subject: [PATCH] improve doc (based on review) --- docs/guide/validation.rst | 10 +++++----- mongoengine/base/datastructures.py | 2 +- mongoengine/fields.py | 2 +- mongoengine/mongodb_support.py | 2 +- tests/utils.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/guide/validation.rst b/docs/guide/validation.rst index 793a797a..5f0346bd 100644 --- a/docs/guide/validation.rst +++ b/docs/guide/validation.rst @@ -2,15 +2,15 @@ Document Validation ==================== -By design, mongoengine strictly validates the documents right before they are inserted in MongoDB +By design, MongoEngine strictly validates the documents right before they are inserted in MongoDB and make sure they are consistent with the fields defined in your models. Mongoengine will not validate a document when an object is loaded from the DB into an instance -of your model but this operation will fail under some circumstances (e.g: if there is a field in -the document fetched from the database that is not defined in your model) +of your model but this operation will fail under some circumstances (e.g. if there is a field in +the document fetched from the database that is not defined in your model). -Builtin validation +Built-in validation ================= Mongoengine provides different fields that encapsulate the corresponding validation @@ -73,7 +73,7 @@ Note that `clean` runs before the validation when you save a Document. * Adding custom Field classes -We recommend as much as possible to use the standard field but it is also possible +We recommend as much as possible to use fields provided by MongoEngine. However, it is also possible to subclass a Field and encapsulate some validation by overriding the `validate` method .. code-block:: python diff --git a/mongoengine/base/datastructures.py b/mongoengine/base/datastructures.py index fafc08b7..b693b914 100644 --- a/mongoengine/base/datastructures.py +++ b/mongoengine/base/datastructures.py @@ -217,7 +217,7 @@ class EmbeddedDocumentList(BaseList): Filters the list by only including embedded documents with the given keyword arguments. - This method only supports simple comparison (e.g: .filter(name='John Doe')) + This method only supports simple comparison (e.g. .filter(name='John Doe')) and does not support operators like __gte, __lte, __icontains like queryset.filter does :param kwargs: The keyword arguments corresponding to the fields to diff --git a/mongoengine/fields.py b/mongoengine/fields.py index aa5aa805..591cf01a 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -385,7 +385,7 @@ class DecimalField(BaseField): :param max_value: Validation rule for the maximum acceptable value. :param force_string: Store the value as a string (instead of a float). Be aware that this affects query sorting and operation like lte, gte (as string comparison is applied) - and some query operator won't work (e.g: inc, dec) + and some query operator won't work (e.g. inc, dec) :param precision: Number of decimal places to store. :param rounding: The rounding rule from the python decimal library: diff --git a/mongoengine/mongodb_support.py b/mongoengine/mongodb_support.py index b20ebc1e..423cd92b 100644 --- a/mongoengine/mongodb_support.py +++ b/mongoengine/mongodb_support.py @@ -15,5 +15,5 @@ def get_mongodb_version(): :return: tuple(int, int) """ - version_list = get_connection().server_info()['versionArray'][:2] # e.g: (3, 2) + version_list = get_connection().server_info()['versionArray'][:2] # e.g. (3, 2) return tuple(version_list) diff --git a/tests/utils.py b/tests/utils.py index 27d5ada7..be7a8095 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,7 +4,7 @@ import unittest from nose.plugins.skip import SkipTest from mongoengine import connect -from mongoengine.connection import get_db, disconnect_all +from mongoengine.connection import disconnect_all, get_db from mongoengine.mongodb_support import get_mongodb_version @@ -51,7 +51,7 @@ def _decorated_with_ver_requirement(func, mongo_version_req, oper): ran against MongoDB < v3.6. :param mongo_version_req: The mongodb version requirement (tuple(int, int)) - :param oper: The operator to apply (e.g: operator.ge) + :param oper: The operator to apply (e.g. operator.ge) """ def _inner(*args, **kwargs): mongodb_v = get_mongodb_version()