Exemplo n.º 1
0
def setup( dbh ):
    """ populate the database with basic, essential data """

    if get_datalogger():
        get_clsreg().sync()
        session.commit()

    dbsession = dbh.session()

    EK.bulk_update( ek_initlist, dbsession=dbsession )
    Group.bulk_insert( essential_groups, dbsession=dbsession )
    UserClass.bulk_insert( system_userclass, dbsession=dbsession )

    group_id = Group._id('_SysAdm_', dbsession)
    file = File( path='/', group_id = group_id, permanent = True )
    dbsession.add( file )
    file.type = 'file/folder'
    file.mimetype = 'application/x-directory'

    cerr('INFO: root password is %s\n' % root_password)
Exemplo n.º 2
0
def setup_db( *ops ):
    """ setup the database (create tables, etc) and populate with basic data """

    base = get_base()

    # WARN: use alembic to create initial tables
    #base.metadata.create_all()

    with transaction.manager:
        if get_datalogger():
            get_clsreg().sync()

    with transaction.manager:
        EK.bulk_insert( ek_initlist )
        Group.bulk_insert( essential_groups )

        file = File( path='/', type='file/folder', mimetype='application/x-directory',
                    group_id = Group._id('_SysAdm_'), permanent = True )
        dbsession.add( file )

        for op in ops:
            op()