Esempio n. 1
0
def get_parameters_by_tmpl(dbpersonality):
    ret = defaultdict(dict)

    session = object_session(dbpersonality)
    paramdef_holder = dbpersonality.archetype.paramdef_holder
    if not paramdef_holder:
        return ret

    param_definitions = paramdef_holder.param_definitions
    parameters = get_parameters(session, personality=dbpersonality)

    for param_def in param_definitions:
        value = None
        for param in parameters:
            value = param.get_path(param_def.path, compel=False)
            if (value is None) and param_def.default:
                value = validate_value("default for path=%s" % param_def.path,
                                       param_def.value_type, param_def.default)
            if value is not None:
                ## coerce string list to list
                if param_def.value_type == 'list':
                    value = string_to_list(value)

                get_path_under_top(param_def.path, value,
                                   ret[param_def.template])

        ## if all parameters are not defined still generate empty template
        if param_def.template not in ret:
            ret[param_def.template] = defaultdict()
    return ret
Esempio n. 2
0
def get_parameters_by_tmpl(dbpersonality):
    ret = defaultdict(dict)

    session = object_session(dbpersonality)
    paramdef_holder = dbpersonality.archetype.paramdef_holder
    if not paramdef_holder:
        return ret

    param_definitions = paramdef_holder.param_definitions
    parameters = get_parameters(session, personality=dbpersonality)

    for param_def in param_definitions:
        value = None
        for param in parameters:
            value = param.get_path(param_def.path, compel=False)
            if (value is None) and param_def.default:
                value = validate_value("default for path=%s" % param_def.path,
                                       param_def.value_type, param_def.default)
            if value is not None:
                ## coerce string list to list
                if param_def.value_type == 'list':
                    value = string_to_list(value)

                get_path_under_top(param_def.path, value,
                                   ret[param_def.template])

        ## if all parameters are not defined still generate empty template
        if param_def.template not in ret:
            ret[param_def.template] = defaultdict()
    return ret
Esempio n. 3
0
def get_parameters_by_feature(dbfeaturelink):
    ret = {}
    paramdef_holder = dbfeaturelink.feature.paramdef_holder
    if not paramdef_holder:
        return ret

    param_definitions = paramdef_holder.param_definitions
    parameters = get_parameters(object_session(dbfeaturelink),
                                personality=dbfeaturelink.personality)

    for param_def in param_definitions:
        value = None
        for param in parameters:
            value = param.get_feature_path(dbfeaturelink,
                                           param_def.path, compel=False)
            if not value and param_def.default:
                value = validate_value("default for path=%s" % param_def.path,
                                       param_def.value_type, param_def.default)
            if value is not None:
                if param_def.value_type == 'list':
                    value = string_to_list(value)
                ret[param_def.path] = value
    return ret
Esempio n. 4
0
def get_parameters_by_feature(dbfeaturelink):
    ret = {}
    paramdef_holder = dbfeaturelink.feature.paramdef_holder
    if not paramdef_holder:
        return ret

    param_definitions = paramdef_holder.param_definitions
    parameters = get_parameters(object_session(dbfeaturelink),
                                personality=dbfeaturelink.personality)

    for param_def in param_definitions:
        value = None
        for param in parameters:
            value = param.get_feature_path(dbfeaturelink,
                                           param_def.path,
                                           compel=False)
            if not value and param_def.default:
                value = validate_value("default for path=%s" % param_def.path,
                                       param_def.value_type, param_def.default)
            if value is not None:
                if param_def.value_type == 'list':
                    value = string_to_list(value)
                ret[param_def.path] = value
    return ret