gws.base.model.related_field¶
Base class for related fields.
Source code: gws.base.model.related_field
Module Contents¶
- class gws.base.model.related_field.Config¶
Bases:
gws.base.model.field.Config
- class gws.base.model.related_field.Link(*args, **kwargs)¶
Bases:
gws.DataLink table of a many-to-many relationship.
- class gws.base.model.related_field.Object¶
Bases:
gws.base.model.field.ObjectBase related field.
Links features of the field’s model to features of other database models. Provides the relationship description, conversion of related features to and from props, and database helpers to read and update the keys of related features. Subclasses describe the link in
configure_relationship.- model: gws.DatabaseModel¶
The model of this field.
- rel: Relationship¶
The relationship of this field.
- configure_relationship()¶
Set up the relationship
rel.Called after configuration. The base implementation does nothing.
- configure_widget()¶
- do_init_related(dst_feature, mc)¶
- find_relatable_features(search, mc)¶
- from_props(feature, mc)¶
- get_model(uid: str) → gws.DatabaseModel¶
Return a model by uid.
- Parameters:
uid – The model uid.
- Returns:
The model.
- Raises:
gws.ConfigurationError – If the model is not found.
- key_column(ref: RelRef) → gws.lib.sa.Column¶
Return the key column of a relationship side.
- Parameters:
ref – The relationship side.
- Returns:
The column
ref.keyNameofref.model.
- key_for_uid(model: gws.DatabaseModel, key_column: gws.lib.sa.Column, uid: gws.FeatureUid, mc: gws.ModelContext)¶
Return the key value of the feature with the given uid.
- Parameters:
model – The model to query.
key_column – The key column.
uid – The feature uid.
mc – The model context.
- Returns:
The key value, or None if the feature is not found.
- link_column(name: str) → gws.lib.sa.Column¶
Return a column of the link table.
- Parameters:
name – The column name.
- Returns:
The column.
- link_table() → gws.lib.sa.Table¶
Return the link table of the relationship.
- post_configure()¶
- related_field(dst: RelRef) → gws.ModelField | None¶
Find the field of a related model that describes the reverse relationship.
- Parameters:
dst – The related side of the relationship.
- Returns:
The field of
dst.modelwhose relationship starts atdst.modelanddst.keyName, or None if there is no such field.
- related_models()¶
- to_props(feature, mc)¶
- class gws.base.model.related_field.Props¶
Bases:
gws.base.model.field.Props