AquilaConfig & Env — Aquilia Documentation
Comprehensive guide and documentation for AquilaConfig & Env in the Aquilia framework. View API reference, examples, and implementation patterns.
import from 'lucide-react' AquilaConfig aquilia.pyconfig — Python-native, zero-YAML environment configuration AquilaConfig is the base class for environment-specific configuration. Subclass it once per environment, override only what changes, and use Env to bind fields to OS environment variables or Secret to protect sensitive values. All of this lives directly in workspace.py. Why Python-native config , , , ].map(( ) => ( ))} AquilaConfig — layered inheritance Subclass AquilaConfig once per deployment environment. The env attribute is the identifier — AQ_ENV=prod selects the class whose env = "prod". Only override the nested sections that change between environments; everything else is inherited from the base class automatically. Built-in section types Each section type provides typed defaults, IDE hover docs, and a clean interface for overriding only what changes. Extend any of them inside your AquilaConfig subclass. Section Key fields Purpose ))} AquilaConfig.Server — full reference Every attribute maps directly to a uvicorn.Config parameter and is forwarded automatically. No glue code required — adding a new field here is all you need. Env — live environment variable binding Env is a descriptor that reads from os.environ at attribute access time. Values already in the process environment (from Docker, Kubernetes, or CI/CD) always win over source-code defaults. The dotenv loader is triggered automatically on first access — you never call load_dotenv() manually. Auto-cast rules (no cast= specified) Raw string value Resolved Python value Type \'', ' ', 'dict (JSON)'], ['"hello"', '"hello"', 'str (fallback)'], ].map(([raw, out, t], i) => ( ))} Secret — redacted sensitive values Secret wraps any sensitive value — API keys, database passwords, signing keys. The underlying value never appears in repr(), str(), log output, or serialised config until you call .reveal() deliberately. The resolution order is: env var → literal value → default. — safe to log # >>> repr(BaseEnv.auth.secret_key) # "Secret(env='AQ_SECRET_KEY', *required*)" # Only .reveal() returns the actual value key = BaseEnv.auth.secret_key.reveal() # → "actual-key-value-from-env" # Properties is_required = BaseEnv.auth.secret_key.is_required # → True env_var_name = BaseEnv.auth.secret_key.env_name # → "AQ_SECRET_KEY"`} /> Never commit literal Secret values. Secret(value="...") is for local dev only. In staging and production always point to an env var: Secret(env="MY_KEY", required=True). AquilaConfig.PasswordHasher Controls the password hashing algorithm used by the auth subsystem. Class-method shortcuts provide sensible defaults for each algorithm. Algorithm Factory method Notes ))} AquilaConfig.Signing — cryptographic signing Controls the aquilia.signing module that backs session cookies, CSRF tokens, one-time activation links, cache integrity checks, and signed cookies. Each subsystem uses an isolated namespace salt so cross-subsystem token reuse is cryptographically impossible. @section — custom config grouping The @section decorator marks any arbitrary nested class as a named config section included in the serialised to_dict() output. Use it for app-specific subsystems that don't map to a built-in section type. AquilaConfig.Dotenv — file loading policy Control exactly which .env files are loaded and in what order. Define a nested Dotenv class inside your AquilaConfig subclass. AquilaConfig.Apps — per-module namespaces Place module-specific settings inside a nested class named after the module. Access them via config.apps.. inside that module's services or controllers. Runtime API — to_dict, to_loader, get, for_env Testing patterns ))} )
Go to Homepage