Exemplo n.º 1
0
def check_database_config(config):
    from papaye.models import get_manager
    manager = get_manager(config)
    if manager.get_db_version() < manager.get_sw_version():
        raise ConfigurationError('Your database need to be updated! Run '
                                 '"papaye_evolve path_to_your_config_file.ini" command first')
    conn = config.registry._zodb_databases[''].open()
    if user_root_factory(conn) is None or repository_root_factory(conn) is None:
        raise ConfigurationError('Database does not exist! Run "papaye_init '
                                 'path_to_your_config_file.ini command first')
    return True
Exemplo n.º 2
0
def main(*argv, **kwargs):
    config_file = sys.argv[-1]
    settings = get_appsettings(config_file)
    config = Configurator(settings=settings)
    manager = get_manager(config)
    if manager.get_db_version() >= manager.get_sw_version():
        sys.stdout.write('Your database is already up do date... ')
    else:
        sys.stdout.write('Your database need to be updated... ')
        evolve_to_latest(manager)
    sys.stdout.write('Done!\n')
Exemplo n.º 3
0
def check_database_config(config):
    from papaye.models import get_manager
    manager = get_manager(config)
    if manager.get_db_version() < manager.get_sw_version():
        raise ConfigurationError('Your database need to be updated! Run '
                                 '"papaye_evolve path_to_your_config_file.ini" command first')
    conn = config.registry._zodb_databases[''].open()
    if user_root_factory(conn) is None or repository_root_factory(conn) is None:
        raise ConfigurationError('Database does not exist! Run "papaye_init '
                                 'path_to_your_config_file.ini command first')
    return True
Exemplo n.º 4
0
def create_app_root(dbconn):
    zodb_root = get_database_root(dbconn)
    manager = get_manager(None)
    if manager.key not in zodb_root:
        zodb_root[manager.key] = {manager.package_name: manager.sw_version}
    if "{}_root".format(APP_NAME) not in zodb_root:
        zodb_root["{}_root".format(APP_NAME)] = Root()
    if "user" not in zodb_root["{}_root".format(APP_NAME)]:
        zodb_root["{}_root".format(APP_NAME)]["user"] = Root()
    if "repository" not in zodb_root["{}_root".format(APP_NAME)]:
        zodb_root["{}_root".format(APP_NAME)]["repository"] = Root()
Exemplo n.º 5
0
def create_app_root(dbconn):
    zodb_root = get_database_root(dbconn)
    manager = get_manager(None)
    if manager.key not in zodb_root:
        zodb_root[manager.key] = {manager.package_name: manager.sw_version}
    if '{}_root'.format(APP_NAME) not in zodb_root:
        zodb_root['{}_root'.format(APP_NAME)] = Root('{}_root'.format(APP_NAME))
    if 'user' not in zodb_root['{}_root'.format(APP_NAME)]:
        zodb_root['{}_root'.format(APP_NAME)]['user'] = Root('user_root')
    if 'repository' not in zodb_root['{}_root'.format(APP_NAME)]:
        zodb_root['{}_root'.format(APP_NAME)]['repository'] = Root(
            'repository_root'
        )
Exemplo n.º 6
0
def main(*argv, **kwargs):
    logger = logging.getLogger()
    # logger.disabled = True
    config_file = sys.argv[-1]
    settings = get_appsettings(config_file)
    config = Configurator(settings=settings)
    manager = get_manager(config)
    if manager.get_db_version() >= manager.get_sw_version():
        sys.stdout.write("Your database is already up do date... ")
    else:
        sys.stdout.write("Your database need to be updated... ")
        evolve_to_latest(manager)
        manager.evolve_to_current()
    sys.stdout.write("Done!\n")