Browse Source

Merge pull request #1280 from jcomo/mongokit-doc-update

Update mongokit pattern
pull/1285/head
Markus Unterwaditzer 10 years ago
parent
commit
b7dfa6c363
  1. 4
      docs/patterns/mongokit.rst

4
docs/patterns/mongokit.rst

@ -48,12 +48,14 @@ insert query to the next without any problem. MongoKit is just schemaless
too, but implements some validation to ensure data integrity. too, but implements some validation to ensure data integrity.
Here is an example document (put this also into :file:`app.py`, e.g.):: Here is an example document (put this also into :file:`app.py`, e.g.)::
from mongokit import ValidationError
def max_length(length): def max_length(length):
def validate(value): def validate(value):
if len(value) <= length: if len(value) <= length:
return True return True
raise Exception('%s must be at most %s characters long' % 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 return validate
class User(Document): class User(Document):

Loading…
Cancel
Save