gws.config.util¶
Helpers for configure methods: create common children and find providers.
Source code: gws.config.util
Module Contents¶
- gws.config.util.configure_database_provider_for(obj: gws.Node, ext_type: str | None = None) bool¶
Set the database provider of an object.
The provider is looked up by the
dbUidconfig, then taken from the internal_defaultDbconfig, then found by the extension type. The result is stored inobj.db.- Parameters:
obj – Object to configure.
ext_type – Extension type of the provider, e.g.
postgres. Defaults to the object’sextType.
- Returns:
Trueif a provider was set.- Raises:
gws.Error – If
dbUidis configured but not found, or if no provider is found.
- gws.config.util.configure_finders_for(obj: gws.Node, with_default=False) bool¶
Create the finders of an object.
Finders are created from the
findersconfig, using the object’screate_findermethod if it has one. The result is stored inobj.finders.- Parameters:
obj – Object to configure.
with_default – If no finders are configured, create one finder with an empty config.
- Returns:
Trueif finders are configured or a default finder was created.
- gws.config.util.configure_models_for(obj: gws.Node, with_default=False) bool¶
Create the models of an object.
Models are created from the
modelsconfig, using the object’screate_modelmethod if it has one. The result is stored inobj.models.- Parameters:
obj – Object to configure.
with_default – If no models are configured, create one model with an empty config.
- Returns:
Trueif models are configured or a default model was created.
- gws.config.util.configure_provider_for(obj: gws.Node, cls: type) bool¶
Set the provider of an object.
If
provideris configured, a shared provider object is created from it. Otherwise, the internal_defaultProviderconfig is used, if it is an instance ofcls. The result is stored inobj.provider.- Parameters:
obj – Object to configure.
cls – Provider class.
- Returns:
Trueif a provider was set.- Raises:
gws.Error – If no provider is found.
- gws.config.util.configure_source_layers_for(obj: gws.Node, layers: list[gws.SourceLayer], is_group: bool = None, is_image: bool = None, is_queryable: bool = None, is_visible: bool = None) bool¶
Select the source layers of an object.
If
sourceLayersis configured, it is used as a filter onlayers. Otherwise, the internal_defaultSourceLayersconfig is used as is, if set. Otherwise,layersare filtered by the given flags. The result is stored inobj.sourceLayers.- Parameters:
obj – Object to configure.
layers – Source layers to select from.
is_group – Filter by the group flag.
is_image – Filter by the image flag.
is_queryable – Filter by the queryable flag.
is_visible – Filter by the visible flag.
- Returns:
Always
True.
- gws.config.util.configure_templates_for(obj: gws.Node, extra: list | None = None) bool¶
Create the templates of an object.
Templates are created from the
templatesconfig and fromextra, using the object’screate_templatemethod if it has one. The result is stored inobj.templates.- Parameters:
obj – Object to configure.
extra – Additional template configs, appended after the configured ones.
- Returns:
Trueif at least one template was created.