apis_core.generic.abc#
Module Contents#
Classes#
Data#
API#
- apis_core.generic.abc.logger = 'getLogger(...)'#
- class apis_core.generic.abc.GenericModel(*args, **kwargs)#
Bases:
django.db.models.Model- classmethod check(**kwargs)#
- __repr__()#
- property get_self_content_type#
- classmethod get_listview_url()#
- classmethod get_createview_url()#
- classmethod get_importview_url()#
- classmethod get_openapi_tags()#
- classmethod get_namespace_prefix()#
- classmethod get_namespace_uri()#
- classmethod get_rdf_types()#
- classmethod get_count()#
- get_edit_url()#
- get_duplicate_url()#
- get_enrich_url()#
- get_absolute_url()#
- get_delete_url()#
- get_merge_url(other_id)#
- get_select_merge_or_enrich_url()#
- get_create_success_url(request: Optional[django.http.request.HttpRequest] = None)#
- get_update_success_url(request: Optional[django.http.request.HttpRequest] = None)#
- get_delete_success_url(request: Optional[django.http.request.HttpRequest] = None)#
- get_api_detail_endpoint()#
- classmethod get_change_permission()#
- classmethod get_add_permission()#
- classmethod get_delete_permission()#
- classmethod get_view_permission()#
- classmethod get_verbose_name_plural()#
- classmethod get_verbose_name()#
- classmethod valid_import_url(uri: str)#
Check if an URI is a can be imported. The exact fetching logic for an URI is defined in the import_definitions attribute of the class. import_definitions has to be a dict, mapping a regex matching the URI to a callable taking the URI as an argument. This method check if there is a callable defined for this URI.
- classmethod get_data_and_normalized_uri(uri: str) Tuple[dict, str]#
- classmethod fetch_from(uri: str)#
Normalize the URI and extract the autocomplete data. Then try to fetch data from an URI: Check if there is import logic configured for this URI and if so, use that import logic to fetch the data. Finally, combine the fetched data and the autocomplete data.
- classmethod import_from(uri: str, allow_empty: bool = True)#
Fetch data from an URI and create a model instance using that data. If the allow_empty argument is set, this also creates a model instance if the data fetched was empty. This might make sense if you still want to create an instance and attach the URI to it.
- import_from_dict_subset(**data)#
Import attributes of this instance from data in a dict. We iterate through the individual values of the dict and a) only set them if the instance has an attribute matching the key and b) use the fields clean method to check if the value validates. If it does not validate, we return the validation error in the errors dict.
- import_data(data)#
- get_merge_charfield_value(other: django.db.models.CharField, field: django.db.models.CharField)#
- get_merge_textfield_value(other: django.db.models.TextField, field: django.db.models.TextField)#
- get_merge_booleanfield(other: django.db.models.BooleanField, field: django.db.models.BooleanField)#
- get_field_value_after_merge(other, field)#
This method finds the value of a field after merging other into self. It first tries to find a merge method that is specific to that field (merge_{fieldname}) and then tries to find a method that is specific to the type of the field (merge_{fieldtype}) If neither of those exist, it uses the others field value if the field in self is not set, otherwise it keeps the value in self.
- merge_fields(other)#
This method iterates through the model fields and uses the get_field_value_after_merge method to copy values from other to self. It is called by the merge_with method.
- merge_with(entities)#
- duplicate()#
- uri_set()#
- uri_set_with_importer()#