Esempio n. 1
0
def init(args):
    home, closer = get_site_home(args, args.site)
    if HOME_KEY in home:
        args.parser.error("Evolution is already initialized.")
    for service in sorted(get_services(args), key=lambda x: x.pkgname):
        evolution = service(home)
        print_status(args, evolution)
    transaction.commit()
Esempio n. 2
0
def remove_setting(args):
    home, closer = get_site_home(args, args.site)
    site = args.app.registry.sites.get(args.site)
    schema = site.application.settings_schema()
    settings = home['settings']
    sequence = schema.get_value(settings, args.path)
    del sequence[args.index]
    home['settings'] = settings  # Force persistence
    transaction.commit()

    _list_settings(settings, args.out)
Esempio n. 3
0
def set_setting(args):
    try:
        value = args.value
        if args.json:
            value = json.loads(value)
        home, closer = get_site_home(args, args.site)
        site = args.app.registry.sites.get(args.site)
        schema = site.application.settings_schema()
        serial = schema.serialize(home['settings'])
        schema.set_value(serial, args.path, value)
        home['settings'] = schema.deserialize(serial)
        transaction.commit()

        _list_settings(home['settings'], args.out)
    except colander.Invalid, e:
        args.parser.error(str(e))
Esempio n. 4
0
def add_setting(args):
    try:
        value = args.value
        if args.json:
            value = json.loads(value)
        home, closer = get_site_home(args, args.site)
        site = args.app.registry.sites.get(args.site)
        schema = site.application.settings_schema()
        serial = schema.serialize(home['settings'])
        sequence = schema.get_value(serial, args.path)
        index = getattr(args, 'index', None)
        if index is not None:
            sequence.insert(index, value)
        else:
            sequence.append(value)
        home['settings'] = schema.deserialize(serial)
        transaction.commit()

        _list_settings(home['settings'], args.out)
    except colander.Invalid, e:
        args.parser.error(str(e))
Esempio n. 5
0
def list_settings(args):
    home, closer = get_site_home(args, args.site)
    _list_settings(home['settings'], args.out)
Esempio n. 6
0
def get_versions(args):
    home, closer = get_site_home(args, args.site)
    versions = home.get(HOME_KEY)
    if not versions:
        args.parser.error("Evolution is not initialized.")
    return home, versions, closer