gws.plugin.model_field.related_linked_feature_list¶
Related linked feature list field.
Represents an M:N relationship between two models via a link table (“associative entity”):
+------------+ +-------------------------------+ +-----------+
| this model | | linkTableName | | toModel |
+------------+ +-------------------------------+ +-----------+
| fromColumn |-------<<| linkFromColumn linkToColumn |>>-------| toColumn |
+------------+ +-------------------------------+ +-----------+
The value of the field is the list of linked features of the related model.
fromColumn and toColumn default to the primary keys. The link table
must be in the same database as this model.
When a feature is written, the rows of the link table are synchronized with
the field value: missing links are inserted, links to features no longer in
the list are deleted. The linked features themselves are not changed. When a
related feature is created together with features of this model, links to
them are inserted. Without a configured widget, the field uses a
featureList widget.
Example:
fields+ {
name "tags"
type "relatedLinkedFeatureList"
toModel "model_tag"
linkTableName "edit.poi_tag"
linkFromColumn "poi_id"
linkToColumn "tag_id"
}
Source code: gws.plugin.model_field.related_linked_feature_list
Package Contents¶
- class gws.plugin.model_field.related_linked_feature_list.Config¶
Bases:
gws.base.model.related_field.ConfigField listing features of another model, related via a link table.
- class gws.plugin.model_field.related_linked_feature_list.Object¶
Bases:
gws.base.model.related_field.ObjectRelated linked feature list field object.
- attributeType¶
- after_create(feature, mc)¶
- after_create_related(dst_feature, mc)¶
- after_select(features, mc)¶
- after_update(feature, mc)¶
- after_write(feature, key, mc: gws.ModelContext)¶
Synchronize the link table with the field value of a written feature.
Does nothing if the user may not write the field or the maximum relation depth is reached.
- Parameters:
feature – The created or updated feature.
key – Value of the key column of the feature.
mc – The model context.
- configure_relationship()¶
- create_links(links, mc)¶
Insert links into the link table.
- Parameters:
links –
(src_key, dst_key)tuples.mc – The model context.
- delete_links(links, mc)¶
Delete links from the link table.
- Parameters:
links –
(src_key, dst_key)tuples.mc – The model context.
- get_links(left_keys, mc)¶
Read the links of the given keys from the link table.
- Parameters:
left_keys – Key values of features of this model.
mc – The model context.
- Returns:
A set of
(src_key, dst_key)tuples.
- class gws.plugin.model_field.related_linked_feature_list.Props¶