def main(args): ''' Launches application with passed in Args ''' global RDFW_RESET global SERVER_CHECK # test to see if a forced definition reset is required if cbool(args.get("rdfw_reset",True)): RDFW_RESET = True else: RDFW_RESET = False # test to see if the server status check should be skipped if cbool(args.get("server_check",True)): SERVER_CHECK = True else: SERVER_CHECK = False # initialize the rdfframework rdfw(config=app.config, reset=RDFW_RESET, server_check = SERVER_CHECK, root_file_path=os.path.realpath('./')) # load default data into the server core ctx = app.test_request_context('/') with ctx: rdfw().load_default_data() host = '0.0.0.0' port = 8081 # Debug ssl_context = 'adhoc' app.run(host=host, port=port, #threaded=True, #ssl_context=ssl_context, debug=True)
def calculate_value(value, obj, prop): if DEBUG: debug = True else: debug = False if value.startswith("<<"): _lookup_value = value.replace("<<","").replace(">>","") if debug: print(value) if "|" in _lookup_value: value_array = _lookup_value.split("|") _lookup_value = pyuri(value_array[0]) _class_uri = iri(pyuri(value_array[1])) else: _lookup_value = pyuri(_lookup_value) _class_uri = iri(prop.kds_classUri) _query_data = obj.query_data for _subject, _data in _query_data.items(): if _class_uri in make_list(_data.get("rdf_type")): #if _class_uri == "<obi_Assertion>": x=y return cbool(_data.get(pyuri(_lookup_value)), False) elif value.startswith("!--"): return_val = value if value == "!--api_url": return_val = obj.api_url if value == "!--base_url": return_val = obj.base_url if value == "!--base_api_url": return_val = obj.base_api_url if value == "!--subjectUri": _query_data = obj.query_data _class_uri = iri(prop.kds_classUri) for _subject, _data in _query_data.items(): if _class_uri in make_list(_data.get("rdf_type")): return_val = _subject return return_val else: return cbool(value, False)
def get_api_field_json(field, instructions, instance, user_info, item_permissions=None): '''This function will read through the RDF defined info and proccess the json to return the correct values for the instance, security and details''' if DEBUG: debug = True else: debug = False if item_permissions is None: item_permissions = [] _rdf_app = rdfw().app instance = instance.replace(".html", "") # get class property info try: _class_prop = getattr(rdfw(), field.get(\ 'kds_classUri')).kds_properties.get(field.get('kds_propUri'),{}) except: _class_prop = {} # merge the class prop attributes with the api prop #field = {**_class_prop, **field} temp_field = _class_prop.copy() temp_field.update(field) field = temp_field # Determine Security Access _new_field = {} _access_level = get_field_security_access(field, user_info, item_permissions) if "acl_Read" not in _access_level: return None _new_field['accessLevel'] = _access_level # get api instance info _api_instance_info = {} _api_field_instance_type_list = make_list(field.get('kds_apiInstance', field.get(\ 'kds_apiDefault', {}).get('kds_apiInstance', []))) if debug: print("instance type list: ",_api_field_instance_type_list) if debug: print("instance: ", instance) for _field_instance in _api_field_instance_type_list: if _field_instance.get('kds_apiInstanceType') == instance: _api_instance_info = _field_instance if debug: print("instance info\n",_api_instance_info) # Determine the field paramaters _new_field['kds_apiFieldName'] = _api_instance_info.get('kds_apiFieldName', field.get(\ "kds_apiFieldName", field.get('kds_apiDefault', {}).get(\ 'kds_apiFieldName', ""))) _new_field['kds_fieldType'] = _api_instance_info.get('kds_fieldType', field.get(\ 'kds_fieldType', field.get('kds_apiDefault', {}).get('kds_fieldType', ""))) if not isinstance(_new_field['kds_fieldType'], dict): _new_field['kds_fieldType'] = {"rdf_type":_new_field['kds_fieldType']} _new_field['kds_apiLabelName'] = _api_instance_info.get('kds_apiLabelName', \ field.get("kds_apiLabelName", field.get('kds_apiDefault', {}).get(\ 'kds_apiLabelName', ""))) _new_field['kds_apiFieldHelp'] = _api_instance_info.get('kds_apiFieldHelp', \ field.get("apiFieldHelp", field.get('apiDefault', {}).get(\ 'kds_apiFieldHelp', ""))) _new_field['kds_apiFieldOrder'] = _api_instance_info.get('kds_apiFieldOrder', \ field.get("kds_apiFieldOrder", field.get('kds_apiDefault', {}).get(\ 'kds_apiFieldOrder', ""))) _new_field['kds_apiLayoutRow'] = _api_instance_info.get('kds_apiLayoutRow', \ field.get("kds_apiLayoutRow", field.get('kds_apiDefault', {}).get(\ 'kds_apiLayoutRow', ""))) _new_field['rdfs_range'] = field.get('rdfs_range') _new_field['kds_defaultVal'] = _api_instance_info.get('kds_defaultVal',\ field.get('kds_defaultVal')) _new_field['kds_propUri'] = field.get('kds_propUri') _new_field['kds_classUri'] = field.get('kds_classUri') _new_field['kds_returnValue'] = field.get('kds_returnValue') # get applicationActionList _new_field['kds_actionList'] = make_set(_api_instance_info.get(\ 'kds_applicationAction', set())) _new_field['kds_actionList'].union(make_set(field.get('kds_applicationAction', set()))) _new_field['kds_actionList'] = list(_new_field['kds_actionList']) if debug: print("action List:_______________", _new_field['kds_actionList']) if "kdr_RemoveFromApi" in\ _new_field['kds_actionList']: return None # get valiator list if field.get('kds_overrideValidation'): _new_field['kds_validators'] = field.get('kds_overrideValidation') else: _new_field['kds_validators'] = make_list(\ _api_instance_info.get('kds_apiValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_apiValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_propertyValidation', [])) # get processing list _new_field['kds_processors'] = make_list(_api_instance_info.get('kds_apiProcessing', [])) _new_field['kds_processors'] += make_list(field.get('kds_apiProcessing', [])) _new_field['kds_processors'] += make_list(field.get('kds_propertyProcessing', [])) if debug: if field['kds_propUri'] == "schema_image": x=1 # get required state _required = False _field_req_var = cbool(field.get('kds_requiredField')) if (field.get('kds_propUri') in make_list(field.get('kds_classInfo', {}).get(\ 'kds_primaryKey', []))) or _field_req_var: _required = True if field.get('kds_classUri') in make_list(field.get('kds_requiredByDomain', {})): _required = True if _field_req_var == False: _required = False _new_field['kds_required'] = _required # Determine EditState if ("acl_Write" in _access_level) and ("kdr_NotEditable" \ not in _new_field['kds_actionList']): _new_field['editable'] = True else: _new_field['editable'] = False return _new_field
def get_field_json(field, instructions, instance, user_info, item_permissions=None): '''This function will read through the RDF defined info and proccess the json to return the correct values for the instance, security and details''' debug = False if item_permissions is None: item_permissions = [] _rdf_app = rdfw().app instance = instance.replace(".html", "") # Determine Security Access _new_field = {} _access_level = get_field_security_access(field, user_info, item_permissions) if "acl_Read" not in _access_level: return None _new_field['accessLevel'] = _access_level # get form instance info _form_instance_info = {} _form_field_instance_type_list = make_list(field.get('kds_formInstance', field.get(\ 'kds_formDefault', {}).get('kds_formInstance', []))) #print("instance type list: ",_form_field_instance_type_list) #print("instance: ", instance) for _field_instance in _form_field_instance_type_list: if _field_instance.get('kds_formInstanceType') == instance: _form_instance_info = _field_instance #print("instance info\n",_form_instance_info) # Determine the field paramaters _new_field['kds_formFieldName'] = _form_instance_info.get('kds_formFieldName', field.get(\ "kds_formFieldName", field.get('kds_formDefault', {}).get(\ 'kds_formFieldName', ""))) _new_field['kds_fieldType'] = _form_instance_info.get('kds_fieldType', field.get(\ 'kds_fieldType', field.get('kds_formDefault', {}).get('kds_fieldType', ""))) if not isinstance(_new_field['kds_fieldType'], dict): _new_field['kds_fieldType'] = {"rdf_type":_new_field['kds_fieldType']} _new_field['kds_formLabelName'] = _form_instance_info.get('kds_formLabelName', \ field.get("kds_formLabelName", field.get('kds_formDefault', {}).get(\ 'kds_formLabelName', ""))) _new_field['kds_formFieldHelp'] = _form_instance_info.get('kds_formFieldHelp', \ field.get("formFieldHelp", field.get('formDefault', {}).get(\ 'kds_formFieldHelp', ""))) _new_field['kds_formFieldOrder'] = _form_instance_info.get('kds_formFieldOrder', \ field.get("kds_formFieldOrder", field.get('kds_formDefault', {}).get(\ 'kds_formFieldOrder', ""))) _new_field['kds_formLayoutRow'] = _form_instance_info.get('kds_formLayoutRow', \ field.get("kds_formLayoutRow", field.get('kds_formDefault', {}).get(\ 'kds_formLayoutRow', ""))) _new_field['kds_propUri'] = field.get('kds_propUri') _new_field['kds_classUri'] = field.get('kds_classUri') _new_field['rdfs_range'] = field.get('rdfs_range') _new_field['kds_defaultVal'] = _form_instance_info.get('kds_defaultVal',\ field.get('kds_defaultVal')) # get applicationActionList _new_field['kds_actionList'] = make_set(_form_instance_info.get(\ 'kds_applicationAction', set())) _new_field['kds_actionList'].union(make_set(field.get('kds_applicationAction', set()))) _new_field['kds_actionList'] = list(_new_field['kds_actionList']) #print("action List:_______________", _new_field['kds_actionList']) if "kdr_RemoveFromForm" in\ _new_field['kds_actionList']: return None # get valiator list if field.get('kds_overrideValidation'): _new_field['kds_validators'] = field.get('kds_overrideValidation') else: _new_field['kds_validators'] = make_list(\ _form_instance_info.get('kds_formValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_formValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_propertyValidation', [])) # get processing list _new_field['kds_processors'] = make_list(_form_instance_info.get('kds_formProcessing', [])) _new_field['kds_processors'] += make_list(field.get('kds_formProcessing', [])) _new_field['kds_processors'] += make_list(field.get('kds_propertyProcessing', [])) if debug: if field['kds_propUri'] == "schema_image": x=1 # get required state _required = False _field_req_var = cbool(field.get('kds_requiredField')) if (field.get('kds_propUri') in make_list(field.get('kds_classInfo', {}).get(\ 'kds_primaryKey', []))) or _field_req_var: _required = True if field.get('kds_classUri') in make_list(field.get('kds_requiredByDomain', {})): _required = True if _field_req_var == False: _required = False _new_field['kds_required'] = _required # Determine EditState if ("acl_Write" in _access_level) and ("kdr_NotEditable" \ not in _new_field['kds_actionList']): _new_field['editable'] = True else: _new_field['editable'] = False # Determine css classes css = _form_instance_info.get('kds_overrideCss', field.get('kds_overrideCss', \ instructions.get('kds_overrideCss', None))) if css is None: css = _rdf_app.get('kds_formDefault', {}).get('kds_fieldCss', '') css = css.strip() + " " + instructions.get('kds_propertyAddOnCss', '') css = css.strip() + " " + _form_instance_info.get('kds_addOnCss', field.get(\ 'kds_addOnCss', field.get('kds_formDefault', {}).get('kds_addOnCss', ''))) css = css.strip() _new_field['kds_css'] = css #print("field_json:\n", json.dumps(_new_field, indent=4)) return _new_field
def rdf_class_forms(form_name, form_instance=None): """View for displaying forms Args: form_name -- main form url part form_instance -- specific instance of the form (new, edit) params: id -- the lookup value for the form to lookup data """ _display_mode = False _form_path = "/".join(remove_null([form_name, form_instance])) # test to see if the form exists _form_exists = rdfw().form_exists(_form_path) if _form_exists is False: return render_template("error_page_template.html", error_message="The web address is invalid") # if the form exists continue instance_uri = _form_exists.get("instance_uri") form_uri = _form_exists.get("form_uri") # generate the form class form_class = rdf_framework_form_factory(_form_path, \ base_url=url_for("rdfw_core.base_path"), current_url=request.url) # test to see if the form requires a login login_message = None if cbool(form_class.rdf_instructions.get("kds_loginRequired",False)) is \ True: if isinstance(current_user.is_authenticated, bool): auth = current_user.is_authenticated else: auth = current_user.is_authenticated() if not auth: current_app.login_manager.login_message = \ "Please log in to access this page" #return current_app.login_manager.unauthorized() # if request method is post if request.method == "POST": # let form load with post data form = form_class(subject_uri=request.args.get("id")) # validate the form if form.validate(): # if validated save the form obj = form.save() if form.save_state == "success": if isinstance(form.save_results, User): login_user(form.save_results) return redirect(form.redirect_url(params=request.args)) else: redirect_url = form.redirect_url(params=request.args) if redirect_url != "!--currentpage": return redirect(redirect_url) #form = form_class(subject_uri=request.args.get("id")) # if not POST, check the args and form instance else: # if params are present for any forms that are not in any of # the below forms remove the params if instance_uri not in ["kdr_EditForm", "kdr_DisplayForm", "kdr_Login"]\ and request.args.get("id"): redirect_url = url_for("app.rdf_class_forms", form_name=form_name, form_instance=form_instance) return redirect(redirect_url) # if the there is no ID argument and on the editform instance -> # redirect to NewForm if instance_uri in ["kdr_EditForm","kdr_DisplayForm"] and \ not request.args.get("id"): redirect_url = url_for("app.base_path") + \ rdfw().get_form_path(form_uri, "kdr_NewForm") return redirect(redirect_url) # if the display form does not have an ID return an error if instance_uri in ["kdr_DisplayForm"] and not request.args.get("id"): return render_template("error_page_template.html", error_message="The item does not exist") # if the there is an ID argument and on the editform instance -> # query for the save item if request.args.get("id") and instance_uri \ in ["kdr_EditForm","kdr_DisplayForm"]: if instance_uri == "kdr_DisplayForm": _display_mode = True form_data = rdfw().get_obj_data(form_class(\ no_query=True, subject_uri=request.args.get("id"))) #pp.pprint(form_data) form = form_class(form_data['obj_data'],\ query_data=form_data['query_data'],\ subject_uri=request.args.get("id")) #pp.pprint(form) if not (len(form_data['query_data']) > 0): return render_template("error_page_template.html", error_message="The item does not exist") # if not on EditForm or DisplayForm render form else: form = form_class() template = render_template( "/forms/default/app_form_template.html", actionUrl=request.url, form=form, display_mode = _display_mode, dateFormat = rdfw().app.get(\ 'kds_dataFormats',{}).get('kds_javascriptDateFormat',''), debug=request.args.get("debug",False), login_message=login_message) return template
def rdf_class_forms(form_name, form_instance=None): """View for displaying forms Args: form_instance -- Type of form (new, edit) params: id -- the subject uri of the form data to lookup """ _display_mode = False _form_path = "/".join(remove_null([form_name, form_instance])) # test to see if the form exists _form_exists = rdfw().form_exists(_form_path) if _form_exists is False: return render_template( "error_page_template.html", error_message="The web address is invalid") # if the form exists continue instance_uri = _form_exists.get("instance_uri") form_uri = _form_exists.get("form_uri") # generate the form class form_class = rdf_framework_form_factory(_form_path, \ base_url=url_for("open_badge.base_path"), current_url=request.url) # test to see if the form requires a login login_message = None if cbool(form_class.rdf_instructions.get("kds_loginRequired",False)) is \ True: if isinstance(current_user.is_authenticated, bool): auth = current_user.is_authenticated else: auth = current_user.is_authenticated() if not auth: current_app.login_manager.login_message = \ "Please log in to access this page" return current_app.login_manager.unauthorized() # if request method is post if request.method == "POST": # let form load with post data form = form_class(subject_uri=request.args.get("id")) # validate the form if form.validate(): # if validated save the form obj = form.save() if form.save_state == "success": if isinstance(form.save_results, User): login_user(form.save_results) #x=y return redirect(form.redirect_url(params=request.args)) #form = form_class(subject_uri=request.args.get("id")) # if not POST, check the args and form instance else: # if params are present for any forms that are not in any of # the below forms remove the params if instance_uri not in ["kdr_EditForm", "kdr_DisplayForm", "kdr_Login"]\ and request.args.get("id"): redirect_url = url_for("open_badge.rdf_class_forms", form_name=form_name, form_instance=form_instance) return redirect(redirect_url) # if the there is no ID argument and on the editform instance -> # redirect to NewForm if instance_uri in ["kdr_EditForm","kdr_DisplayForm"] and \ not request.args.get("id"): redirect_url = url_for("open_badge.base_path") + \ rdfw().get_form_path(form_uri, "kdr_NewForm") return redirect(redirect_url) # if the display form does not have an ID return an error if instance_uri in ["kdr_DisplayForm"] and not request.args.get("id"): return render_template( "error_page_template.html", error_message="The item does not exist") # if the there is an ID argument and on the editform instance -> # query for the save item if request.args.get("id") and instance_uri \ in ["kdr_EditForm","kdr_DisplayForm"]: if instance_uri == "kdr_DisplayForm": _display_mode = True form_data = rdfw().get_obj_data(form_class(\ no_query=True, subject_uri=request.args.get("id"))) #pp.pprint(form_data['form_data']) form = form_class(form_data['obj_data'],\ query_data=form_data['query_data'],\ subject_uri=request.args.get("id")) if not (len(form_data['query_data']) > 0): return render_template( "error_page_template.html", error_message="The item does not exist") # if not on EditForm or DisplayForm render form else: form = form_class() template = render_template( "/forms/default/app_form_template.html", actionUrl=request.url, form=form, display_mode = _display_mode, dateFormat = rdfw().app.get(\ 'kds_dataFormats',{}).get('kds_javascriptDateFormat',''), debug=request.args.get("debug",False), login_message=login_message) return template
def __init__(self, value): new_val = cbool(value) if new_val is None: raise TypeError("'%s' is not a boolean value" % value) self.value = new_val
def __init__(self, active=True): self.active = cbool(active)
def get_api_field_json(field, instructions, instance, user_info, item_permissions=None): '''This function will read through the RDF defined info and proccess the json to return the correct values for the instance, security and details''' if DEBUG: debug = True else: debug = False if item_permissions is None: item_permissions = [] _rdf_app = rdfw().app instance = instance.replace(".html", "") # get class property info try: _class_prop = getattr(rdfw(), field.get(\ 'kds_classUri')).kds_properties.get(field.get('kds_propUri'),{}) except: _class_prop = {} # merge the class prop attributes with the api prop #field = {**_class_prop, **field} temp_field = _class_prop.copy() temp_field.update(field) field = temp_field # Determine Security Access _new_field = {} _access_level = get_field_security_access(field, user_info, item_permissions) if "acl_Read" not in _access_level: return None _new_field['accessLevel'] = _access_level # get api instance info _api_instance_info = {} _api_field_instance_type_list = make_list(field.get('kds_apiInstance', field.get(\ 'kds_apiDefault', {}).get('kds_apiInstance', []))) if debug: print("instance type list: ", _api_field_instance_type_list) if debug: print("instance: ", instance) for _field_instance in _api_field_instance_type_list: if _field_instance.get('kds_apiInstanceType') == instance: _api_instance_info = _field_instance if debug: print("instance info\n", _api_instance_info) # Determine the field paramaters _new_field['kds_apiFieldName'] = _api_instance_info.get('kds_apiFieldName', field.get(\ "kds_apiFieldName", field.get('kds_apiDefault', {}).get(\ 'kds_apiFieldName', ""))) _new_field['kds_fieldType'] = _api_instance_info.get('kds_fieldType', field.get(\ 'kds_fieldType', field.get('kds_apiDefault', {}).get('kds_fieldType', ""))) if not isinstance(_new_field['kds_fieldType'], dict): _new_field['kds_fieldType'] = {"rdf_type": _new_field['kds_fieldType']} _new_field['kds_apiLabelName'] = _api_instance_info.get('kds_apiLabelName', \ field.get("kds_apiLabelName", field.get('kds_apiDefault', {}).get(\ 'kds_apiLabelName', ""))) _new_field['kds_apiFieldHelp'] = _api_instance_info.get('kds_apiFieldHelp', \ field.get("apiFieldHelp", field.get('apiDefault', {}).get(\ 'kds_apiFieldHelp', ""))) _new_field['kds_apiFieldOrder'] = _api_instance_info.get('kds_apiFieldOrder', \ field.get("kds_apiFieldOrder", field.get('kds_apiDefault', {}).get(\ 'kds_apiFieldOrder', ""))) _new_field['kds_apiLayoutRow'] = _api_instance_info.get('kds_apiLayoutRow', \ field.get("kds_apiLayoutRow", field.get('kds_apiDefault', {}).get(\ 'kds_apiLayoutRow', ""))) _new_field['rdfs_range'] = field.get('rdfs_range') _new_field['kds_defaultVal'] = _api_instance_info.get('kds_defaultVal',\ field.get('kds_defaultVal')) _new_field['kds_propUri'] = field.get('kds_propUri') _new_field['kds_classUri'] = field.get('kds_classUri') _new_field['kds_returnValue'] = field.get('kds_returnValue') # get applicationActionList _new_field['kds_actionList'] = make_set(_api_instance_info.get(\ 'kds_applicationAction', set())) _new_field['kds_actionList'].union( make_set(field.get('kds_applicationAction', set()))) _new_field['kds_actionList'] = list(_new_field['kds_actionList']) if debug: print("action List:_______________", _new_field['kds_actionList']) if "kdr_RemoveFromApi" in\ _new_field['kds_actionList']: return None # get valiator list if field.get('kds_overrideValidation'): _new_field['kds_validators'] = field.get('kds_overrideValidation') else: _new_field['kds_validators'] = make_list(\ _api_instance_info.get('kds_apiValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_apiValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_propertyValidation', [])) # get processing list _new_field['kds_processors'] = make_list( _api_instance_info.get('kds_apiProcessing', [])) _new_field['kds_processors'] += make_list( field.get('kds_apiProcessing', [])) _new_field['kds_processors'] += make_list( field.get('kds_propertyProcessing', [])) if debug: if field['kds_propUri'] == "schema_image": x = 1 # get required state _required = False _field_req_var = cbool(field.get('kds_requiredField')) if (field.get('kds_propUri') in make_list(field.get('kds_classInfo', {}).get(\ 'kds_primaryKey', []))) or _field_req_var: _required = True if field.get('kds_classUri') in make_list( field.get('kds_requiredByDomain', {})): _required = True if _field_req_var == False: _required = False _new_field['kds_required'] = _required # Determine EditState if ("acl_Write" in _access_level) and ("kdr_NotEditable" \ not in _new_field['kds_actionList']): _new_field['editable'] = True else: _new_field['editable'] = False return _new_field
def get_field_json(field, instructions, instance, user_info, item_permissions=None): '''This function will read through the RDF defined info and proccess the json to return the correct values for the instance, security and details''' debug = False if item_permissions is None: item_permissions = [] _rdf_app = rdfw().app instance = instance.replace(".html", "") # Determine Security Access _new_field = {} _access_level = get_field_security_access(field, user_info, item_permissions) if "acl_Read" not in _access_level: return None _new_field['accessLevel'] = _access_level # get form instance info _form_instance_info = {} _form_field_instance_type_list = make_list(field.get('kds_formInstance', field.get(\ 'kds_formDefault', {}).get('kds_formInstance', []))) #print("instance type list: ",_form_field_instance_type_list) #print("instance: ", instance) for _field_instance in _form_field_instance_type_list: if _field_instance.get('kds_formInstanceType') == instance: _form_instance_info = _field_instance #print("instance info\n",_form_instance_info) # Determine the field paramaters _new_field['kds_formFieldName'] = _form_instance_info.get('kds_formFieldName', field.get(\ "kds_formFieldName", field.get('kds_formDefault', {}).get(\ 'kds_formFieldName', ""))) _new_field['kds_fieldType'] = _form_instance_info.get('kds_fieldType', field.get(\ 'kds_fieldType', field.get('kds_formDefault', {}).get('kds_fieldType', ""))) if not isinstance(_new_field['kds_fieldType'], dict): _new_field['kds_fieldType'] = {"rdf_type": _new_field['kds_fieldType']} _new_field['kds_formLabelName'] = _form_instance_info.get('kds_formLabelName', \ field.get("kds_formLabelName", field.get('kds_formDefault', {}).get(\ 'kds_formLabelName', ""))) _new_field['kds_formFieldHelp'] = _form_instance_info.get('kds_formFieldHelp', \ field.get("formFieldHelp", field.get('formDefault', {}).get(\ 'kds_formFieldHelp', ""))) _new_field['kds_formFieldOrder'] = _form_instance_info.get('kds_formFieldOrder', \ field.get("kds_formFieldOrder", field.get('kds_formDefault', {}).get(\ 'kds_formFieldOrder', ""))) _new_field['kds_formLayoutRow'] = _form_instance_info.get('kds_formLayoutRow', \ field.get("kds_formLayoutRow", field.get('kds_formDefault', {}).get(\ 'kds_formLayoutRow', ""))) _new_field['kds_propUri'] = field.get('kds_propUri') _new_field['kds_classUri'] = field.get('kds_classUri') _new_field['rdfs_range'] = field.get('rdfs_range') _new_field['kds_defaultVal'] = _form_instance_info.get('kds_defaultVal',\ field.get('kds_defaultVal')) # get applicationActionList _new_field['kds_actionList'] = make_set(_form_instance_info.get(\ 'kds_applicationAction', set())) _new_field['kds_actionList'].union( make_set(field.get('kds_applicationAction', set()))) _new_field['kds_actionList'] = list(_new_field['kds_actionList']) #print("action List:_______________", _new_field['kds_actionList']) if "kdr_RemoveFromForm" in\ _new_field['kds_actionList']: return None # get valiator list if field.get('kds_overrideValidation'): _new_field['kds_validators'] = field.get('kds_overrideValidation') else: _new_field['kds_validators'] = make_list(\ _form_instance_info.get('kds_formValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_formValidation', [])) _new_field['kds_validators'] += make_list(\ field.get('kds_propertyValidation', [])) # get processing list _new_field['kds_processors'] = make_list( _form_instance_info.get('kds_formProcessing', [])) _new_field['kds_processors'] += make_list( field.get('kds_formProcessing', [])) _new_field['kds_processors'] += make_list( field.get('kds_propertyProcessing', [])) if debug: if field['kds_propUri'] == "schema_image": x = 1 # get required state _required = False _field_req_var = cbool(field.get('kds_requiredField')) if (field.get('kds_propUri') in make_list(field.get('kds_classInfo', {}).get(\ 'kds_primaryKey', []))) or _field_req_var: _required = True if field.get('kds_classUri') in make_list( field.get('kds_requiredByDomain', {})): _required = True if _field_req_var == False: _required = False _new_field['kds_required'] = _required # Determine EditState if ("acl_Write" in _access_level) and ("kdr_NotEditable" \ not in _new_field['kds_actionList']): _new_field['editable'] = True else: _new_field['editable'] = False # Determine css classes css = _form_instance_info.get('kds_overrideCss', field.get('kds_overrideCss', \ instructions.get('kds_overrideCss', None))) if css is None: css = _rdf_app.get('kds_formDefault', {}).get('kds_fieldCss', '') css = css.strip() + " " + instructions.get('kds_propertyAddOnCss', '') css = css.strip() + " " + _form_instance_info.get('kds_addOnCss', field.get(\ 'kds_addOnCss', field.get('kds_formDefault', {}).get('kds_addOnCss', ''))) css = css.strip() _new_field['kds_css'] = css #print("field_json:\n", json.dumps(_new_field, indent=4)) return _new_field