Browse Source

verbage

pull/1280/head
Jonathan Como 10 years ago
parent
commit
bd4921194e
  1. 7
      docs/patterns/mongokit.rst

7
docs/patterns/mongokit.rst

@ -54,7 +54,8 @@ Here is an example document (put this also into :file:`app.py`, e.g.)::
def validate(value):
if len(value) <= length:
return True
raise ValidationError('%s must be at most {0} characters long'.format(length))
# must have %s in error format string to have mongokit place key in there
raise ValidationError('%s must be at most {} characters long'.format(length))
return validate
class User(Document):
@ -76,9 +77,7 @@ Here is an example document (put this also into :file:`app.py`, e.g.)::
This example shows you how to define your schema (named structure), a
validator for the maximum character length and uses a special MongoKit feature
called `use_dot_notation`. When you define a ValidationError, you can add the `%s`
into the format string to have the value placed in there for the final error message.
ValueErrors can also be thrown as an alternative. Per default MongoKit behaves like a python
called `use_dot_notation`. Per default MongoKit behaves like a python
dictionary but with `use_dot_notation` set to ``True`` you can use your
documents like you use models in nearly any other ORM by using dots to
separate between attributes.

Loading…
Cancel
Save