Created
October 20, 2010 09:43
-
-
Save namlook/636106 to your computer and use it in GitHub Desktop.
A '_type' field that can be used to automatically case documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mongokit import * | |
import numpy as np | |
class MongoMatrix(Document): | |
structure = {} | |
use_autorefs = True | |
use_dot_notation=True | |
atomic_save = True | |
class Test(MongoMatrix): | |
structure = {'new':unicode} | |
class Run(Document): | |
structure = {'title':unicode, | |
'result': MongoMatrix, } | |
use_autorefs = True | |
use_dot_notation=True | |
atomic_save = True | |
connection = Connection() | |
connection.register([Run, MongoMatrix, Test]) | |
run = connection.test.example.Run() | |
test1 = connection.test.example.Test() | |
test1.new=u'we' | |
test1.save() | |
run.result = test1 | |
run.save() | |
#The first save above will convert run.result into its base class | |
#When you save it again, the run.result base class is called and | |
#verification fails with: | |
#structureError: unknown fields : [u'new'] | |
run.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment