httk.serve.web.widgets.core

The public contracts for static httk-serve widgets.

Attributes

MAX_WIDGET_ASSET_BYTES

Largest individual trusted widget asset accepted by WidgetAsset.

SUPPORTED_WIDGET_ASSET_CONTENT_TYPES

The deliberately small content-type vocabulary for internal widget assets.

WidgetRenderer

BUILTIN_WIDGETS

Classes

WidgetAsset

An immutable, deployment-relative asset declared by trusted widget code.

WidgetContext

Immutable request and page information made available to widgets.

WidgetRenderResult

An explicitly trusted HTML result returned by a widget.

Widget

Advanced immutable widget definition protocol.

FunctionWidget

An immutable adapter for the common module-level render facade.

WidgetRegistry

Registry for built-ins; aliases never participate in site resolution.

Functions

function_widget(→ FunctionWidget)

Wrap a callable as a FunctionWidget.

trusted_html(→ WidgetRenderResult)

Mark a widget's reviewed HTML output as trusted.

Module Contents

httk.serve.web.widgets.core.MAX_WIDGET_ASSET_BYTES = 1000000[source]

Largest individual trusted widget asset accepted by WidgetAsset.

httk.serve.web.widgets.core.SUPPORTED_WIDGET_ASSET_CONTENT_TYPES[source]

The deliberately small content-type vocabulary for internal widget assets.

class httk.serve.web.widgets.core.WidgetAsset[source]

An immutable, deployment-relative asset declared by trusted widget code.

path is relative to /_httk/serve/assets/ and is never interpreted as a filesystem path. The engine serves only assets it has registered while rendering this site instance.

path: str[source]
content: bytes[source]
content_type: str[source]
class httk.serve.web.widgets.core.WidgetContext[source]

Immutable request and page information made available to widgets.

route: str[source]
render_mode: str[source]
widget_id: str[source]
query: collections.abc.Mapping[str, str][source]
postvars: collections.abc.Mapping[str, str][source]
page: collections.abc.Mapping[str, object][source]
source_path: pathlib.Path[source]
url_for: collections.abc.Callable[[str], str][source]
absolute_url_for: collections.abc.Callable[[str], str][source]
table_runtime: object | None = None[source]
class httk.serve.web.widgets.core.WidgetRenderResult[source]

An explicitly trusted HTML result returned by a widget.

html: str[source]
assets: tuple[WidgetAsset, Ellipsis] = ()[source]
class httk.serve.web.widgets.core.Widget[source]

Bases: Protocol

Advanced immutable widget definition protocol.

property name: str[source]
property source: str[source]
render(context: WidgetContext, **props: object) str | WidgetRenderResult[source]
httk.serve.web.widgets.core.WidgetRenderer[source]
class httk.serve.web.widgets.core.FunctionWidget[source]

An immutable adapter for the common module-level render facade.

name: str[source]
render_function: WidgetRenderer[source]
source: str[source]
render(context: WidgetContext, **props: object) str | WidgetRenderResult[source]
httk.serve.web.widgets.core.function_widget(render: WidgetRenderer, *, name: str = '', source: str = '') FunctionWidget[source]

Wrap a callable as a FunctionWidget.

Site-local modules normally need no wrapper: a module-level render is discovered automatically. The helper is useful for explicit definitions.

httk.serve.web.widgets.core.trusted_html(value: str) WidgetRenderResult[source]

Mark a widget’s reviewed HTML output as trusted.

class httk.serve.web.widgets.core.WidgetRegistry[source]

Registry for built-ins; aliases never participate in site resolution.

register(widget: Widget, *, alias: str | None = None) None[source]
resolve(name: str) Widget | None[source]
available() list[tuple[str, str]][source]
httk.serve.web.widgets.core.BUILTIN_WIDGETS[source]