Added CollectionManager, made connection module
All connection-related functions are now in connection.py. Created a ConnectionManager class for interacting with a collection in the database. Top-level document classes have an instance of a ConnectionManager (Document.collection). Defined a 'save' method on top-level document's that uses the collection manager's '_save_document' method to save the document to the database. Added tests for CollectionManagers -- all unit tests now require a valid connection to the database, which is set up in the tests' setUp method.
This commit is contained in:
@@ -61,7 +61,13 @@ class EmbeddedDocumentField(BaseField):
|
||||
def _to_python(self, value):
|
||||
return value
|
||||
|
||||
def _to_mongo(self, value):
|
||||
return self.document._to_mongo(value)
|
||||
|
||||
def _validate(self, value):
|
||||
"""Make sure that the document instance is an instance of the
|
||||
EmbeddedDocument subclass provided when the document was defined.
|
||||
"""
|
||||
if not isinstance(value, self.document):
|
||||
raise ValidationError('Invalid embedded document instance '
|
||||
'provided to an EmbeddedDocumentField')
|
||||
|
||||
Reference in New Issue
Block a user