Пример #1
0
 def addUser(self):
     if not (DBSession.query(User).filter(
             User.name == 'distractionbike').first()):
         md5 = hashlib.md5('secret'.encode()).hexdigest()
         user = User(name='distractionbike', password_md5=md5)
         DBSession.add(user)
         return user
Пример #2
0
 def addPost(self):
     post = Post(journal_name='distractionbike',
                 title='First Post',
                 lede='First lede',
                 text='<b>My body</b>')
     DBSession.add(post)
     DBSession.flush()
     return post
Пример #3
0
 def addUser(self):
     if not (DBSession
             .query(User)
             .filter(User.name == 'distractionbike')
             .first()):
         md5 = hashlib.md5('secret'.encode()).hexdigest()
         user = User(name='distractionbike', password_md5=md5)
         DBSession.add(user)
         return user
Пример #4
0
 def addPost(self):
     post = Post(
         journal_name='distractionbike',
         title='First Post',
         lede='First lede',
         text='<b>My body</b>')
     DBSession.add(post)
     DBSession.flush()
     return post
Пример #5
0
 def addComment(self):
     comment = Comment(post_id=1, user_id='bob', text='First Comment')
     DBSession.add(comment)
     DBSession.flush()
     return comment
Пример #6
0
 def addJournal(self):
     journal = Journal(name='distractionbike')
     DBSession.add(journal)
     return journal
Пример #7
0
 def setUpDb(self):
     engine = create_engine('sqlite://')
     Base.metadata.create_all(engine)
     DBSession.configure(bind=engine)
Пример #8
0
 def tearDown(self):
     DBSession.remove()
Пример #9
0
 def addComment(self):
     comment = Comment(post_id=1, user_id='bob', text='First Comment')
     DBSession.add(comment)
     DBSession.flush()
     return comment
Пример #10
0
 def addJournal(self):
     journal = Journal(name='distractionbike')
     DBSession.add(journal)
     return journal
Пример #11
0
 def setUpDb(self):
     engine = create_engine('sqlite://')
     Base.metadata.create_all(engine)
     DBSession.configure(bind=engine)
Пример #12
0
 def tearDown(self):
     DBSession.remove()
Пример #13
0
            )


if __name__ == '__main__':
    from okarchive.models import siteRoot
    import transaction
    import sys
    from sqlalchemy import engine_from_config

    from pyramid.paster import (
        get_appsettings,
        setup_logging,
    )

    from okarchive.models import (
        DBSession,
        Base,
        Journal,
        Post,
        User,
    )

    config_uri = sys.argv[1]
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)

    journal = siteRoot['journals']['distractionbike']
    import_post(journal)
    transaction.commit()
Пример #14
0
                             )

if __name__ == '__main__':
    from okarchive.models import siteRoot
    import transaction
    import sys
    from sqlalchemy import engine_from_config

    from pyramid.paster import (
        get_appsettings,
        setup_logging,
        )

    from okarchive.models import (
        DBSession,
        Base,
        Journal,
        Post,
        User,
        )


    config_uri = sys.argv[1]
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)

    journal = siteRoot['journals']['distractionbike']
    import_post(journal)
    transaction.commit()