Module

app.compiler

Compilation pipeline from mutable setup state to runtime state.

Classes

AppCompiler 2
Compiles app setup state into immutable runtime state.

Compiles app setup state into immutable runtime state.

Methods

freeze 3
def freeze(self, app: object, run_debug_checks: Callable[[], None], sync_runtime_aliases: Callable[[], None]) -> None
Parameters
Name Type Description
app
run_debug_checks
sync_runtime_aliases
Internal Methods 1
__init__ 4
def __init__(self, config: AppConfig, registry: AppRegistry, mutable_state: MutableAppState, runtime_state: RuntimeAppState) -> None
Parameters
Name Type Description
config
registry
mutable_state
runtime_state

Functions

_collect_builtin_middleware 5 list
Append builtin middleware (static, safe_target, sse_lifecycle, etc.) to list.
def _collect_builtin_middleware(config: AppConfig, middleware_list: list, *, router: object | None = None, oob_registry: OOBRegistry | None = None, debug_wiring: RuntimeDebugWiring | None = None) -> list
Parameters
Name Type Description
config AppConfig
middleware_list list
router object | None Default:None
oob_registry OOBRegistry | None Default:None
debug_wiring RuntimeDebugWiring | None Default:None
Returns
list
_compile_routes 2 Router
Build router from pending routes.
def _compile_routes(pending_routes: list, providers: dict[type, Callable[..., Any]] | None) -> Router
Parameters
Name Type Description
pending_routes list
providers dict[type, Callable[..., Any]] | None
Returns
Router
_reject_reserved_prefix_collisions 2 None
Raise if any pending route starts with a framework-reserved URL prefix. The bl…
def _reject_reserved_prefix_collisions(pending_routes: list, prefix: str) -> None

Raise if any pending route starts with a framework-reserved URL prefix.

The block-fetch dispatcher owns/_frag/**— a user route like /_frag/customwould either shadow the dispatcher or be shadowed by it, and there's no policy where that ambiguity is a good idea. Fail fast with a message that points the user at what to change.

Parameters
Name Type Description
pending_routes list
prefix str
_reject_internal_route_collisions 2 None
Raise if a user route collides with Chirp-owned internal URL space.
def _reject_internal_route_collisions(pending_routes: list, debug_wiring: RuntimeDebugWiring) -> None
Parameters
Name Type Description
pending_routes list
debug_wiring RuntimeDebugWiring
_validate_middleware_ordering 1 None
Check that middleware dependencies are satisfied. CSRFMiddleware requires Sess…
def _validate_middleware_ordering(middleware_list: list) -> None

Check that middleware dependencies are satisfied.

CSRFMiddleware requires SessionMiddleware to wrap it (i.e. Session must be registered before CSRF in add_middleware calls). Detects the mis-ordering early at freeze time rather than waiting for a request to fail.

Parameters
Name Type Description
middleware_list list