pages.resolve

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Page handler argument resolution and result upgrade.

Extracts the parameter-resolution and Page-to-LayoutPage logic from thepage_wrapper closure in App._register_page_handlerinto standalone, testable functions.

Resolution priority for each handler parameter:

  1. request— the…

Page handler argument resolution and result upgrade.

Extracts the parameter-resolution and Page-to-LayoutPage logic from thepage_wrapper closure in App._register_page_handlerinto standalone, testable functions.

Resolution priority for each handler parameter:

  1. request— the Request object (by name or annotation)
  2. Path parameters — from the URL match, with type coercion
  3. Cascade context — from_context.pyproviders
  4. Service providers — registered viaapp.provide()
  5. Extractable dataclasses — from query (GET) or body (POST)

pages.resolve

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

_invoke_provider_factory
function
def _invoke_provider_factory(factory: Callable[..., Any], request: object, cascade_ctx: dict[str, Any]) -> Any

Call a service provider factory, injecting request/cascade_ctx if requested.

Parameters

Name Type Default Description
factory Callable[..., Any]
request object
cascade_ctx dict[str, Any]
_warn_if_page_root_missing
function
def _warn_if_page_root_missing(result: Any) -> None

Warn when Page lacks page_block_name — boosted nav uses block_name as page root.

Parameters

Name Type Default Description
result Any
resolve_kwargs
function async
async def resolve_kwargs(handler: Callable[..., Any], request: Request, cascade_ctx: dict[str, Any], service_providers: dict[type, Callable[..., Any]]) -> dict[str, Any]

Build keyword arguments for a page handler from request context.

Inspects handler's signature and resolves each parameter from the available sources in priority order. For non-GET methods, pre-reads the request body when the handler expects an extractable dataclass.

Parameters

Name Type Default Description
handler Callable[..., Any] The user-defined page handler function.
request Request The current HTTP request.
cascade_ctx dict[str, Any] Merged context from ``_context.py`` providers.
service_providers dict[type, Callable[..., Any]] Type-keyed factories from ``app.provide()``.
upgrade_result
function
def upgrade_result(result: Any, cascade_ctx: dict[str, Any], layout_chain: LayoutChain | None, context_providers: tuple[ContextProvider, ...], request: Request | None = None, template_name: str | None = None) -> Any

Upgrade a Page result to a LayoutPage with layout chain metadata.

If result is aPage, merges cascade context with the page's own context and wraps it in aLayoutPagefor layout composition. If result is aSuspenseand layout_chain has layouts, wraps it in aLayoutSuspenseso the shell is composed with layouts. All other return types pass through unchanged.

Parameters

Name Type Default Description
result Any The handler's return value.
cascade_ctx dict[str, Any] Merged context from ``_context.py`` providers.
layout_chain LayoutChain | None The layout chain for this page route.
context_providers tuple[ContextProvider, ...] The context providers for this page route.
request Request | None None The current request (for LayoutSuspense fragment detection).
template_name str | None None
_merge_result_context
function
def _merge_result_context(cascade_ctx: dict[str, Any], result_ctx: dict[str, Any]) -> dict[str, Any]

Merge page result context with cascade context, preserving shell semantics.

Parameters

Name Type Default Description
cascade_ctx dict[str, Any]
result_ctx dict[str, Any]

View source · /home/runner/work/chirp/chirp/site/../src/chirp/pages/resolve.py:1