def set_parameter(session, param_holder, feature, model, interface_name, path, value, compel=False, preclude=False): """ Handles add parameter as well as update parameter. Parmeters for features will be stored as part of personality as features/<feature_name>/<path> """ dbparameter = Parameter.get_unique(session, holder=param_holder, compel=compel) ## create dbparameter if doesnt exist if not dbparameter: if compel: raise NotFoundException("No parameter of path=%s defined." % path) dbparameter = Parameter(holder=param_holder, value={}) dblink = None if feature: dblink = get_feature_link(session, feature, model, interface_name, param_holder.personality) retval, param_def = validate_parameter(session, path, value, param_holder, dblink) if feature: path = Parameter.feature_path(dblink, path) dbparameter.set_path(path, retval, compel, preclude) dbparameter.param_def = param_def return dbparameter
def del_parameter(session, path, param_holder, feature=None, model=None, interface_name=None): dbparameter = Parameter.get_unique(session, holder=param_holder, compel=True) dblink = None if feature: dblink = get_feature_link(session, feature, model, interface_name, param_holder.personality) match = get_paramdef_for_parameter(session, path, param_holder, dblink) if match and match.rebuild_required: validate_rebuild_required(session, path, param_holder) if dblink: path = Parameter.feature_path(dblink, path) dbparameter.del_path(path) return dbparameter