def setUp(self):
     self.datastore = DS.DataStore(
         master='mongo://localhost:27017/test_db')
     self.session = ThreadLocalORMSession(Session(bind=self.datastore))
     class Parent(MappedClass):
         class __mongometa__:
             name='parent'
             session = self.session
         _id = FieldProperty(S.ObjectId)
     MappedClass.compile_all()
     self.Parent = Parent
     self.session.impl.remove(self.Parent, {})
     self.create_app =  TestApp(MingMiddleware(self._wsgi_create_object))
     self.remove_app =  TestApp(MingMiddleware(self._wsgi_remove_object))
     self.remove_exc =  TestApp(MingMiddleware(self._wsgi_remove_object_exc))
Ejemplo n.º 2
0
 def setUp(self):
     self.datastore = DS.DataStore(
         master='mongo://localhost:27017/test_db')
     self.session = ORMSession(bind=self.datastore)
     class Basic(MappedClass):
         class __mongometa__:
             name='basic'
             session = self.session
         _id = FieldProperty(S.ObjectId)
         a = FieldProperty(int)
         b = FieldProperty([int])
         c = FieldProperty(dict(
                 d=int, e=int))
     MappedClass.compile_all()
     self.Basic = Basic
     self.session.impl.remove(self.Basic, {})
Ejemplo n.º 3
0
 def setUp(self):
     self.bind = DS.DataStore(master='mim:///')
     self.doc_session = Session(self.bind)
     self.orm_session = ORMSession(self.doc_session)
     class Base(MappedClass):
         class __mongometa__:
             name='test_doc'
             session = self.orm_session
             polymorphic_on='type'
             polymorphic_identity='base'
         _id = FieldProperty(S.ObjectId)
         type=FieldProperty(str, if_missing='base')
         a=FieldProperty(int)
     class Derived(Base):
         class __mongometa__:
             polymorphic_identity='derived'
         type=FieldProperty(str, if_missing='derived')
         b=FieldProperty(int)
     MappedClass.compile_all()
     self.Base = Base
     self.Derived = Derived
Ejemplo n.º 4
0
 def setUp(self):
     self.datastore = DS.DataStore(
         master='mongo://localhost:27017/test_db')
     self.session = ORMSession(bind=self.datastore)
     class Parent(MappedClass):
         class __mongometa__:
             name='parent'
             session = self.session
         _id = FieldProperty(int)
         children = RelationProperty('Child')
     class Child(MappedClass):
         class __mongometa__:
             name='child'
             session = self.session
         _id = FieldProperty(int)
         parent_id = ForeignIdProperty('Parent')
         parent = RelationProperty('Parent')
     MappedClass.compile_all()
     self.Parent = Parent
     self.Child = Child
     self.session.impl.remove(self.Parent, {})
     self.session.impl.remove(self.Child, {})
class WikiComment(MappedClass):

    class __mongometa__:
        session = session
        name = 'wiki_comment'

    _id = FieldProperty(schema.ObjectId)
    page_id = ForeignIdProperty('WikiPage')
    text=FieldProperty(str, if_missing='')

    page=RelationProperty('WikiPage')

def _(): pass
    
#{compileall
MappedClass.compile_all()
#}        assert False

WikiPage.query.remove({})
WikiComment.query.remove({})


def snippet1():
    wp = WikiPage(title='FirstPage',
                  text='This is my first page')
    wp
    session
    session.flush()
    session
    session.clear()
    session