Skip to content

Configuration Reference

view.config

B_CLOSE = '}' module-attribute

B_OC = '{}' module-attribute

B_OPEN = '{' module-attribute

Platform: TypeAlias = Literal['windows', 'mac', 'linux', 'macOS', 'Windows', 'Linux', 'Mac', 'MacOS'] module-attribute

__all__ = ('AppConfig', 'ServerConfig', 'UserLogConfig', 'LogConfig', 'MongoConfig', 'PostgresConfig', 'SQLiteConfig', 'DatabaseConfig', 'TemplatesConfig', 'BuildStep', 'BuildConfig', 'Config', 'make_preset', 'load_config') module-attribute

AppConfig

Bases: ConfigModel

app_path: str = ConfigField('app.py:app') class-attribute instance-attribute

loader: Literal['manual', 'simple', 'filesystem', 'patterns', 'custom'] = 'manual' class-attribute instance-attribute

loader_path: Path = Path('./routes') class-attribute instance-attribute

uvloop: Union[Literal['decide'], bool] = 'decide' class-attribute instance-attribute

validate_loader(loader: str) classmethod

validate_loader_path(loader_path: Path, values: dict) classmethod

BuildConfig

Bases: ConfigModel

default_steps: Union[List[str], None] = None class-attribute instance-attribute

parallel: bool = False class-attribute instance-attribute

path: Path = Path('./build') class-attribute instance-attribute

steps: Dict[str, Union[BuildStep, List[BuildStep]]] = ConfigField(default_factory=dict) class-attribute instance-attribute

BuildStep

Bases: ConfigModel

command: Union[str, None, List[str]] = None class-attribute instance-attribute

platform: Union[List[Platform], Platform, None] = None class-attribute instance-attribute

requires: List[str] = ConfigField(default_factory=list) class-attribute instance-attribute

script: Union[Path, None, List[Path]] = None class-attribute instance-attribute

Config

Bases: ConfigModel

app: AppConfig = ConfigField(default_factory=AppConfig) class-attribute instance-attribute

build: BuildConfig = ConfigField(default_factory=BuildConfig) class-attribute instance-attribute

dev: bool = True class-attribute instance-attribute

env: Dict[str, Any] = ConfigField(default_factory=dict) class-attribute instance-attribute

log: LogConfig = ConfigField(default_factory=LogConfig) class-attribute instance-attribute

server: ServerConfig = ConfigField(default_factory=ServerConfig) class-attribute instance-attribute

templates: TemplatesConfig = ConfigField(default_factory=TemplatesConfig) class-attribute instance-attribute

DatabaseConfig

Bases: ConfigModel

mongo: Union[MongoConfig, None] = None class-attribute instance-attribute

mysql: Union[MySQLConfig, None] = None class-attribute instance-attribute

postgres: Union[PostgresConfig, None] = None class-attribute instance-attribute

sqlite: Union[SQLiteConfig, None] = SQLiteConfig(file='view.db') class-attribute instance-attribute

type: Literal['sqlite', 'mysql', 'postgres', 'mongo'] = 'sqlite' class-attribute instance-attribute

LogConfig

Bases: ConfigModel

fancy: bool = True class-attribute instance-attribute

level: Union[Literal['debug', 'info', 'warning', 'error', 'critical'], int] = 'info' class-attribute instance-attribute

pretty_tracebacks: bool = True class-attribute instance-attribute

server_logger: bool = False class-attribute instance-attribute

startup_message: bool = True class-attribute instance-attribute

user: UserLogConfig = ConfigField(default_factory=UserLogConfig) class-attribute instance-attribute

MongoConfig

Bases: ConfigModel

database: str instance-attribute

host: IPv4Address instance-attribute

password: str instance-attribute

port: int instance-attribute

username: str instance-attribute

MySQLConfig

Bases: ConfigModel

database: str instance-attribute

host: IPv4Address instance-attribute

password: str instance-attribute

user: str instance-attribute

PostgresConfig

Bases: ConfigModel

database: str instance-attribute

host: IPv4Address instance-attribute

password: str instance-attribute

port: int instance-attribute

user: str instance-attribute

SQLiteConfig

Bases: ConfigModel

file: Path instance-attribute

ServerConfig

Bases: ConfigModel

backend: Literal['uvicorn', 'hypercorn', 'daphne'] = 'uvicorn' class-attribute instance-attribute

extra_args: Dict[str, Any] = ConfigField(default_factory=dict) class-attribute instance-attribute

host: IPv4Address = IPv4Address('0.0.0.0') class-attribute instance-attribute

port: int = 5000 class-attribute instance-attribute

TemplatesConfig

Bases: ConfigModel

directory: Path = Path('./templates') class-attribute instance-attribute

engine: TemplateEngine = 'view' class-attribute instance-attribute

globals: bool = True class-attribute instance-attribute

locals: bool = True class-attribute instance-attribute

UserLogConfig

Bases: ConfigModel

file_write: FileWriteMethod = 'both' class-attribute instance-attribute

log_file: Union[Path, str, None] = None class-attribute instance-attribute

show_caller: bool = True class-attribute instance-attribute

show_color: bool = True class-attribute instance-attribute

show_time: bool = True class-attribute instance-attribute

show_urgency: bool = True class-attribute instance-attribute

strftime: str = '%H:%M:%S' class-attribute instance-attribute

urgency: Urgency = 'info' class-attribute instance-attribute

load_config(path: Path | None = None, *, directory: Path | None = None) -> Config

Load the configuration file.

Parameters:

Name Type Description Default
path Path | None

Path to get the configuration from.

None
directory Path | None

Where to look for the configuration.

None

make_preset(tp: str, loader: str) -> str