mount_appadapter — hoist a pre-freeze sub-app into a parent app.
Design notes live indocs/rfcs/005-mount-app.md. Summary:
- Sub-app's
pending_routesare path-prefixed and appended to the parent. - Middleware, hooks, loaders, tools, and contract checks are appended — parent's entries run first, sub-app's follow.
- Template globals, filters, error handlers, providers, severity overrides,
and freeze-param providers use parent-wins merge; dropped sub-app
entries are recorded as
MountAppSkips (surfaced later as INFO contract issues in categorymount_app_merge). - Sub-app is marked consumed — subsequent
sub_app.freeze()/run()raiseRuntimeErrorso the caller doesn't accidentally serve a half-mounted standalone runtime.
Deeper page-shell registries (sections, OOB, fragment targets,
layout presets, live blocks, page-discovery state) are not yet supported:
mount_app raises ConfigurationErrorif the sub-app has populated
any of them. RFC 005 §3.3 treats these as "deep contracts" whose silent
override would break shell rendering; a future version may add explicit
collision handling.
app.mount
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
Return"/" + prefix.strip("/").
RaisesConfigurationError if the result would be "/"— mounting at root has no effect vs. registering the routes…
Return the sub-app route's path after applying the mount prefix.
prefix is pre-normalized to "/<something>"(see
normalize_prefix()); pathis whatever the sub-app registered…
Refuse sub-apps that carry state mount_app v1 can't hoist safely.
Mergesub_state into parent_state at prefix.
Does not validate that either state is mutable / pre-freeze — the caller
(App.mount_app) owns the lifecycle checks.
normalize_prefix
function
def normalize_prefix(prefix: str) -> str
Return"/" + prefix.strip("/").
RaisesConfigurationError if the result would be "/"— mounting
at root has no effect vs. registering the routes directly on the parent.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
prefix
|
str
|
— |
prefixed_path
function
def prefixed_path(path: str, prefix: str) -> str
Return the sub-app route's path after applying the mount prefix.
prefix is pre-normalized to "/<something>"(see
normalize_prefix()); pathis whatever the sub-app registered
(expected to start with"/").
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path
|
str
|
— | |
prefix
|
str
|
— |
_check_sub_app_simple
function
def _check_sub_app_simple(sub_state: MutableAppState) -> None
Refuse sub-apps that carry state mount_app v1 can't hoist safely.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
sub_state
|
MutableAppState
|
— |
hoist
function
def hoist(parent_state: MutableAppState, sub_state: MutableAppState, prefix: str) -> None
Mergesub_state into parent_state at prefix.
Does not validate that either state is mutable / pre-freeze — the caller
(App.mount_app) owns the lifecycle checks.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
parent_state
|
MutableAppState
|
— | |
sub_state
|
MutableAppState
|
— | |
prefix
|
str
|
— |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/app/mount.py:1