Merge branch 'master' of git://github.com/flosch/mongoengine

Added unit test for get_or_create, merged flosch's get with
punteney's get.

Conflicts:
	mongoengine/queryset.py
This commit is contained in:
Harry Marr
2010-01-31 13:24:50 +00:00
5 changed files with 111 additions and 16 deletions

View File

@@ -6,7 +6,6 @@ import pymongo
class ValidationError(Exception):
pass
class BaseField(object):
"""A base class for fields in a MongoDB document. Instances of this class
may be added to subclasses of `Document` to define a document's schema.
@@ -76,7 +75,10 @@ class ObjectIdField(BaseField):
def to_mongo(self, value):
if not isinstance(value, pymongo.objectid.ObjectId):
return pymongo.objectid.ObjectId(str(value))
try:
return pymongo.objectid.ObjectId(str(value))
except Exception, e:
raise ValidationError(e.message)
return value
def prepare_query_value(self, value):