Queries now translate keys to correct field names

This commit is contained in:
Harry Marr
2009-12-27 23:08:31 +00:00
parent 17aef253cb
commit 53544c5b0f
3 changed files with 65 additions and 2 deletions

View File

@@ -34,6 +34,9 @@ class StringField(BaseField):
message = 'String value did not match validation regex'
raise ValidationError(message)
def lookup_member(self, member_name):
return None
class IntField(BaseField):
"""An integer field.
@@ -114,6 +117,9 @@ class EmbeddedDocumentField(BaseField):
raise ValidationError('Invalid embedded document instance '
'provided to an EmbeddedDocumentField')
def lookup_member(self, member_name):
return self.document._fields.get(member_name)
class ListField(BaseField):
"""A list field that wraps a standard field, allowing multiple instances
@@ -146,6 +152,9 @@ class ListField(BaseField):
raise ValidationError('All items in a list field must be of the '
'specified type')
def lookup_member(self, member_name):
return self.field.lookup_member(member_name)
class ReferenceField(BaseField):
"""A reference to a document that will be automatically dereferenced on
@@ -194,3 +203,6 @@ class ReferenceField(BaseField):
def validate(self, value):
assert(isinstance(value, (self.document_type, pymongo.dbref.DBRef)))
def lookup_member(self, member_name):
return self.document_type._fields.get(member_name)