fietsboek.config module¶
Configuration parsing for Fietsboek.
Fietsboek mostly relies on pyramid’s INI parsing to get its configuration,
however, there are quite a a few custom values that we add/need. Instead of
manually sprinkling settings.get(...)
all over the code, we’d rather just
do it once at application startup, make sure that the values are well-formed,
provide the user with good feedback if they aren’t, and set the default values
in a single place.
Most of the logic is handled by pydantic.
- class fietsboek.config.Config(**data)¶
Bases:
BaseModel
Object representing the Fietsboek configuration.
-
data_dir:
Annotated
[Path
]¶ Fietsboek data directory.
-
default_tile_layers:
Annotated
[list
]¶ The subset of the default tile layers that should be enabled.
By default, that’s all of them.
- derive_secret(what_for)¶
Derive a secret for other parts of the application.
All secrets are derived from
secret_key
in a deterministic way. See https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/security.html#admonishment-against-secret-sharing on whysecret_key
should not be used directly.
-
email_password:
SecretStr
¶ SMTP password (optional).
-
hittekaart_threads:
int
¶ Number of threads that hittekaart should use.
Defaults to 0, which makes it use as many threads as there are CPU cores.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
thunderforest_access:
LayerAccess
¶ Thunderforest access restriction.
-
thunderforest_key:
SecretStr
¶ API key for the Thunderforest integration.
-
tile_layers:
List
[TileLayerConfig
]¶ Tile layers.
-
data_dir:
- class fietsboek.config.LayerAccess(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Enum discerning whether a layer is publicly accessible or restriced to logged-in users.
Note that in the future, a finer-grained distinction might be possible.
- PUBLIC = 'public'¶
- RESTRICTED = 'restricted'¶
- class fietsboek.config.LayerType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Enum to distinguish base layers and overlay layers.
- BASE = 'base'¶
- OVERLAY = 'overlay'¶
- class fietsboek.config.TileLayerConfig(**data)¶
Bases:
BaseModel
Object representing a single tile layer.
-
access:
LayerAccess
¶ Layer access restriction.
- model_config: ClassVar[ConfigDict] = {'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
url:
AnyUrl
¶ URL of the layer tiles (with placeholders).
-
access:
- exception fietsboek.config.ValidationError(errors)¶
Bases:
Exception
Exception for malformed configurations.
This provides a nice str() representation that can be printed out.
- fietsboek.config.parse(config)¶
Parses the configuration into a
Config
.- Parameters:
config (
dict
) – The configuration dict to parse.- Return type:
- Returns:
The parsed (and validated) configuration.
- Raises:
ValidationError – When the configuration is malformed.