示例#1
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    if 'DATABASE_URL' in os.environ:
        settings['sqlalchemy.url'] = os.environ['DATABASE_URL']
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    # with transaction.manager:
    #     model = MyModel(name='one', value=1)
    #     DBSession.add(model)
    with transaction.manager:
        entry = Entry(title='My first entry', body='Hooray!')
        DBSession.add(entry)
    # with transaction.manager:
    #     encrypted = password_context.encrypt('admin')
    #     admin = User(name='admin', password=encrypted)
    #     DBSession.add(admin)
    with transaction.manager:
        password = os.environ.get('ADMIN_PASSWORD', 'admin')
        encrypted = password_context.encrypt(password)
        admin = User(name=u'admin', password=encrypted)
        DBSession.add(admin)
示例#2
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        encrypted = password_context.encrypt('admin')
        admin = User(name='admin', password=encrypted)      
        DBSession.add(admin)
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        password = os.environ.get('ADMIN_PASSWORD', 'admin')
        encrypted = password_context.encrypt(password)
        admin = User(name=u'admin', password=encrypted)
        DBSession.add(admin)
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    if 'DATABASE_URL' in os.environ:
        settings['sqlalchemy.url'] = os.environ['DATABASE_URL']
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        password = os.environ.get('ADMIN_PASSWORD', 'admin')
        encrypted = password_context.encrypt(password)
        admin = User(username='******', password=encrypted)
        DBSession.add(admin)
示例#5
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = MyModel(name='one', value=1)
        DBSession.add(model)
        entry_model = Entry(title='First entry', body='bla bla bla and ...')
        DBSession.add(entry_model)
        encrypted = password_context.encrypt('admin')
        admin = User(name='admin', password=encrypted)
        DBSession.add(admin)