Skip to content

Configuration

The configuration of webqueue2api can be managed in two different ways:

  • At launch with a configuration file in the same directory as the virtual environment
  • At runtime by modifying the webqueue2api.config symbol directly

Configuration File⚓︎

On import, a ConfigParser INI formatted file is read for configuartion options. This file must be located in the same directory as the virtual environment folder and must be named webqueue2api_config.ini.

A Full Config File

[parser]
# Absolute path to directory containing queue data.
# Default: /home/pier/e/queue/Mail
queue_directory = /etc/queue-cli/queues

# List of queues to ignore. (Comma and space ", " delimited.)
# Default: archives, drafts, inbox, coral
queues_to_ignore = dogs, cats, particularly_pugs

[api]
# Runtime configuration for secure production or convenient development settings.
# Valid options are: prod | dev
# Default: prod
environment = dev

# Token used to encrypt JWT payloads.
# Default: webqueue2api.api.config.generate_random_string
jwt_secret_key = uV0liG9$YgcGE7J!

Changing Settings at Runtime⚓︎

Each package contains package level configuration objects (see: dataclasses on PyPI) in config.py files. All of the configurations are combined into the top level webqueue2api.config symbol.

These configuration objects store default values for each package. Default values can be changed by editing these objects directly or by editing the object values before their use.

Changing the parser's queue directory by editing object values.

import webqueue2api

# Load Queue from default directory
ce_queue = Queue("ce")

# load Queue from modified directory
webqueue2api.config.parser.queue_directory = "/absolute/path"
other_queue = Queue("other")