gws.base.model.field¶
Base model field.
Source code: gws.base.model.field
Module Contents¶
- class gws.base.model.field.Config(*args, **kwargs)¶
Bases:
gws.ConfigWithAccessConfiguration for the model field.
- validators: list[gws.ext.config.modelValidator] | None¶
Additional validators for the field value.
- values: list[gws.ext.config.modelValue] | None¶
Value sources that compute the field value on read, create or update.
- widget: gws.ext.config.modelWidget | None¶
Widget that displays and edits the field in the client.
- class gws.base.model.field.Object¶
Bases:
gws.ModelFieldBase model field.
Provides the field flags, value objects, validators, widget, props and validation. Subclasses implement reading and writing the field value and the conversion between record, feature and props values.
- formatValidator: gws.ModelValidator¶
Validator that checks the format of the value.
- notEmptyValidator: gws.ModelValidator¶
Validator that checks that the value is not empty.
- configure()¶
Configuration hook.
Called when the node is initialized. Raising an exception here aborts the creation of the node.
- configure_flags()¶
Set the field flags from the configuration or the source column.
isPrimaryKey,isRequiredandisAutodefault to the properties of the source column with the field name.isUniqueandisHiddendefault to False.
- configure_validators()¶
Create the configured validators.
Configured
notEmptyandformatvalidators replace the shared default ones, which apply tocreateandupdate.- Returns:
Always True.
- configure_values()¶
Create the configured value objects.
- Returns:
True if values are configured, None otherwise.
- configure_widget()¶
Create the configured widget.
- Returns:
True if a widget is configured, None otherwise.
- create_validator(cfg)¶
Create a validator as a child of this field.
- Parameters:
cfg – The validator configuration.
- Returns:
The validator object.
- describe()¶
Return the description of the source column of this field.
- Returns:
The column description, or None if the source has no such column.
- do_validate(feature, mc)¶
Validate the field value and append errors to
feature.errors.- Parameters:
feature – The feature.
mc – The model context.
- find_relatable_features(search, mc)¶
Find features that can be linked by this field.
- Parameters:
search – The search query.
mc – The model context.
- Returns:
The features found in the related models.
- prop_to_python(feature, value, mc)¶
Convert a client props value to a python value.
- Parameters:
feature – The feature.
value – The value to convert.
mc – The model context.
- Returns:
The converted value.
- props(user)¶
Generate a
Propsstruct for this object.Do not call this method directly, use
gws.props_ofinstead, which also checks permissions.- Parameters:
user – The user for which the props should be generated.
- Returns:
A
Propsobject or a dict. Nested objects are converted to props as well.
- python_to_prop(feature, value, mc)¶
Convert a python value to a client props value.
- Parameters:
feature – The feature.
value – The value to convert.
mc – The model context.
- Returns:
The converted value.
- python_to_raw(feature, value, mc)¶
Convert a python value to a raw source value.
- Parameters:
feature – The feature.
value – The value to convert.
mc – The model context.
- Returns:
The converted value.
- raw_to_python(feature, value, mc)¶
Convert a raw source value to a python value.
- Parameters:
feature – The feature.
value – The value to convert.
mc – The model context.
- Returns:
The converted value.
Return the models related to this field.
- Returns:
A list of models, empty for fields that are not related fields.