Relations¶
We already explained that every entity in can be related to every other entity. We have relation classes for all relation types.
Models¶
- class apis_core.apis_relations.models.AbstractRelation(*args, **kwargs)[source]¶
Abstract super class which encapsulates common logic between the different relations and provides various methods relating to either all or specific relations.
- classmethod add_relation_class_of_entity_class(entity_class)[source]¶
Adds the given entity class to a list which is later retrieved via a dictionary, where the entity class and entity class name define the key and the list of related relation classes as their values.
- Parameters:
entity_class – the class for which the related relation (the current cls) will be saved into a respective list.
- Returns:
None
- classmethod add_relation_field_name_of_entity_class(relation_name, entity_class)[source]¶
Adds the given entity class to a list which is later retrieved via a dictionary, where the entity class defines the key and the list of related relation classes as its values.
- Parameters:
entity_class – the class for which the related relation (the current cls) will be saved into a respective list.
- Returns:
None
- classmethod get_all_relation_classes()[source]¶
Instantiates both lists: ‘_all_relation_classes’ and ‘_all_relation_names’
- Returns:
list of all python classes of the relations defined within this models’ module
- classmethod get_all_relation_names()[source]¶
- Returns:
list of all class names in lower case of the relations defined within this models’ module
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
This method only works on the relation instance of a given relation class. There it returns the instance of an entity on the ‘A’ side of the given relation instance.
Note that if your IDE complains about expecting a ‘str’ instead of ‘None’ this happens because the method ‘get_related_entity_field_nameA()’ is only implemented and overridden at runtime in the function ‘generate_all_fields’ in the class ‘EntityRelationFieldGenerator’.
- Returns:
An entity instance related to the current relation instance
This method only works on the relation instance of a given relation class. There it returns the instance of an entity on the ‘B’ side of the given relation instance.
Note that if your IDE complains about expecting a ‘str’ instead of ‘None’ this happens because the method ‘get_related_entity_field_nameB()’ is only implemented and overridden at runtime in the function ‘generate_all_fields’ in the class ‘EntityRelationFieldGenerator’.
- Returns:
An entity instance related to the current relation instance
- classmethod get_relation_class_of_name(relation_name)[source]¶
- Parameters:
entity_name – str : The name of an relation
- Returns:
The model class of the relation respective to the given name
- classmethod get_relation_classes_of_entity_class(entity_class)[source]¶
:param entity_class : class of an entity for which the related relations should be returned :return: a list of relation classes that are related to the entity class
E.g. AbstractRelation.get_relation_classes_of_entity_class( Person ) -> [ PersonEvent, PersonInstitution, PersonPerson, PersonPlace, PersonWork ]
- classmethod get_relation_classes_of_entity_name(entity_name)[source]¶
:param entity_name : class name of an entity for which the related relations should be returned :return: a list of relation classes that are related to the entity class
E.g. AbstractRelation.get_relation_classes_of_entity_class( ‘person’ ) -> [ PersonEvent, PersonInstitution, PersonPerson, PersonPlace, PersonWork ]
- classmethod get_relation_field_names_of_entity_class(entity_class)[source]¶
:param entity_class : class of an entity for which the related relation class field names should be returned :return: a list of relation class field names that are related to the entity class
E.g. AbstractRelation.get_relation_names_of_entity_class( Person ) -> [ personevent_set, personinstitution_set, related_personA, related_personB, personplace_set, personwork_set ]
- class apis_core.apis_relations.models.EventEvent(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.EventWork(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.InstitutionEvent(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.InstitutionInstitution(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.InstitutionPlace(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.InstitutionWork(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PersonEvent(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PersonInstitution(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PersonPerson(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PersonPlace(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PersonWork(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PlaceEvent(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PlacePlace(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.PlaceWork(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
- class apis_core.apis_relations.models.RelationPublishedQueryset(model=None, query=None, using=None, hints=None)[source]¶
- class apis_core.apis_relations.models.WorkWork(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- Returns:
the python class of the A side of the current relation class or instance
E.g. PersonWork -> Person
- Returns:
the python class of the B side of the current relation class or instance
E.g. PersonWork -> Work
- Returns:
the name of the field of the A side of the current relation class or instance
E.g. PersonWork -> “related_person”
- Returns:
the name of the field of the B side of the current relation class or instance
E.g. PersonWork -> “related_work”
Views¶
- apis_core.apis_relations.views.save_ajax_form(request, entity_type, kind_form, SiteID, ObjectID=False)[source]¶
Tests validity and saves AjaxForms, returns them when validity test fails
- apis_core.apis_relations.views.turn_form_modules_into_dict(form_module_list)[source]¶
Since form classes are loaded dynamically from the respective modules and it’s settings-dependent which modules are imported and which not, it’s better to differentiate here which modules are imported close to their imports and then providing a dict for later extraction of the required form class.