server/__init__.py
branchstable
changeset 2396 8bfb99d7bbcc
parent 2395 e3093fc12a00
child 2458 4d114865098f
child 2588 3a590ff82e99
equal deleted inserted replaced
2395:e3093fc12a00 2396:8bfb99d7bbcc
    43     config.enabled_sources = ('system', 'admin')
    43     config.enabled_sources = ('system', 'admin')
    44     repo = Repository(config, vreg=vreg)
    44     repo = Repository(config, vreg=vreg)
    45     assert len(repo.sources) == 1, repo.sources
    45     assert len(repo.sources) == 1, repo.sources
    46     schema = repo.schema
    46     schema = repo.schema
    47     sourcescfg = config.sources()
    47     sourcescfg = config.sources()
    48     print '-> creating tables...'
    48     _title = '-> creating tables '
       
    49     print _title,
    49     source = sourcescfg['system']
    50     source = sourcescfg['system']
    50     driver = source['db-driver']
    51     driver = source['db-driver']
    51     sqlcnx = repo.system_source.get_connection()
    52     sqlcnx = repo.system_source.get_connection()
    52     sqlcursor = sqlcnx.cursor()
    53     sqlcursor = sqlcnx.cursor()
    53     execute = sqlcursor.execute
    54     execute = sqlcursor.execute
    66         schemasql = sqlschema(schema, driver, user=source['db-user'])
    67         schemasql = sqlschema(schema, driver, user=source['db-user'])
    67     else:
    68     else:
    68         schemasql = sqlschema(schema, driver)
    69         schemasql = sqlschema(schema, driver)
    69         #skip_entities=[str(e) for e in schema.entities()
    70         #skip_entities=[str(e) for e in schema.entities()
    70         #               if not repo.system_source.support_entity(str(e))])
    71         #               if not repo.system_source.support_entity(str(e))])
    71     sqlexec(schemasql, execute)
    72     sqlexec(schemasql, execute, pbtitle=_title)
    72     # install additional driver specific sql files
    73     # install additional driver specific sql files
    73     for fpath in glob(join(config.schemas_lib_dir(), '*.sql.%s' % driver)):
    74     for fpath in glob(join(config.schemas_lib_dir(), '*.sql.%s' % driver)):
    74         print '-> installing', fpath
    75         print '-> installing', fpath
    75         sqlexec(open(fpath).read(), execute, False, delimiter=';;')
    76         sqlexec(open(fpath).read(), execute, False, delimiter=';;')
    76     for directory in config.cubes_path():
    77     for directory in config.cubes_path():
   138     config.creating = False
   139     config.creating = False
   139     config.read_application_schema = read_application_schema
   140     config.read_application_schema = read_application_schema
   140     config.bootstrap_schema = bootstrap_schema
   141     config.bootstrap_schema = bootstrap_schema
   141     config.consider_user_state = True
   142     config.consider_user_state = True
   142     config.set_language = True
   143     config.set_language = True
   143     print '-> application %s initialized.' % config.appid
   144     print '-> database for application %s initialized.' % config.appid
   144 
   145 
   145 
   146 
   146 def initialize_schema(config, schema, mhandler, event='create'):
   147 def initialize_schema(config, schema, mhandler, event='create'):
   147     from cubicweb.server.schemaserial import serialize_schema
   148     from cubicweb.server.schemaserial import serialize_schema
   148     paths = [p for p in config.cubes_path() + [config.apphome]
   149     paths = [p for p in config.cubes_path() + [config.apphome]