Merge remote-tracking branch 'upstream/dev' into integration/uuid

This commit is contained in:
Pau Aliagas
2011-10-04 16:02:58 +02:00
6 changed files with 89 additions and 4 deletions

View File

@@ -282,6 +282,11 @@ class ComplexBaseField(BaseField):
raise ValidationError('Invalid %s item (%s)' % (
self.field.__class__.__name__, str(v)))
# Don't allow empty values if required
if self.required and not value:
raise ValidationError('Field "%s" is required and cannot be empty' %
self.name)
def prepare_query_value(self, op, value):
return self.to_mongo(value)

View File

@@ -460,6 +460,9 @@ class GenericEmbeddedDocumentField(BaseField):
class ListField(ComplexBaseField):
"""A list field that wraps a standard field, allowing multiple instances
of the field to be used as a list in the database.
.. note::
Required means it cannot be empty - as the default for ListFields is []
"""
# ListFields cannot be indexed with _types - MongoDB doesn't support this
@@ -514,6 +517,9 @@ class DictField(ComplexBaseField):
"""A dictionary field that wraps a standard Python dictionary. This is
similar to an embedded document, but the structure is not defined.
.. note::
Required means it cannot be empty - as the default for ListFields is []
.. versionadded:: 0.3
.. versionchanged:: 0.5 - Can now handle complex / varying types of data
"""