goa/skel/loader.py
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Mon, 25 May 2009 00:34:11 +0200
branchstable
changeset 1918 a9db0eb45117
parent 1802 d628defebc17
child 1977 606923dff11b
permissions -rw-r--r--
prepare 3.2.1

if __name__ == '__main__':

    from os.path import dirname, abspath
    from cubicweb import goa
    from cubicweb.goa.goaconfig import GAEConfiguration
    from cubicweb.goa.dbinit import create_user, create_groups

    # compute application's root directory
    APPLROOT = dirname(abspath(__file__))
    # apply monkey patches first
    goa.do_monkey_patch()
    # get application's configuration (will be loaded from app.conf file)
    GAEConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js')
    config = GAEConfiguration('toto', APPLROOT)
    # create default groups
    create_groups()
    if not config['use-google-auth']:
        # create default admin
        create_user('admin', 'admin', ('managers', 'users'))
        # create anonymous user if specified
        anonlogin = config['anonymous-user']
        if anonlogin:
            create_user(anonlogin, config['anonymous-password'], ('guests',))
    print 'content initialized'