httk.serve.web.widgets¶
Static, safe widget authoring contracts and discovery helpers.
Submodules¶
Attributes¶
Largest individual trusted widget asset accepted by |
|
The deliberately small content-type vocabulary for internal widget assets. |
Exceptions¶
A declared OPTIMADE table shell cannot meet the browser protocol. |
Classes¶
An immutable adapter for the common module-level |
|
Advanced immutable widget definition protocol. |
|
An immutable, deployment-relative asset declared by trusted widget code. |
|
Immutable request and page information made available to widgets. |
|
Registry for built-ins; aliases never participate in site resolution. |
|
An explicitly trusted HTML result returned by a widget. |
|
Load |
Functions¶
|
Wrap a callable as a |
|
Mark a widget's reviewed HTML output as trusted. |
Package Contents¶
- httk.serve.web.widgets.MAX_WIDGET_ASSET_BYTES = 1000000[source]¶
Largest individual trusted widget asset accepted by
WidgetAsset.
- httk.serve.web.widgets.SUPPORTED_WIDGET_ASSET_CONTENT_TYPES[source]¶
The deliberately small content-type vocabulary for internal widget assets.
- class httk.serve.web.widgets.FunctionWidget[source]¶
An immutable adapter for the common module-level
renderfacade.- render_function: WidgetRenderer¶
- render(context: WidgetContext, **props: object) str | WidgetRenderResult[source]¶
- class httk.serve.web.widgets.Widget[source]¶
Bases:
ProtocolAdvanced immutable widget definition protocol.
- render(context: WidgetContext, **props: object) str | WidgetRenderResult[source]¶
- class httk.serve.web.widgets.WidgetAsset[source]¶
An immutable, deployment-relative asset declared by trusted widget code.
pathis 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.
- class httk.serve.web.widgets.WidgetContext[source]¶
Immutable request and page information made available to widgets.
- query: collections.abc.Mapping[str, str]¶
- postvars: collections.abc.Mapping[str, str]¶
- page: collections.abc.Mapping[str, object]¶
- source_path: pathlib.Path¶
- url_for: collections.abc.Callable[[str], str]¶
- absolute_url_for: collections.abc.Callable[[str], str]¶
- class httk.serve.web.widgets.WidgetRegistry[source]¶
Registry for built-ins; aliases never participate in site resolution.
- class httk.serve.web.widgets.WidgetRenderResult[source]¶
An explicitly trusted HTML result returned by a widget.
- assets: tuple[WidgetAsset, Ellipsis] = ()¶
- httk.serve.web.widgets.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
renderis discovered automatically. The helper is useful for explicit definitions.
- httk.serve.web.widgets.trusted_html(value: str) WidgetRenderResult[source]¶
Mark a widget’s reviewed HTML output as trusted.
- class httk.serve.web.widgets.SiteWidgetLoader(widgets_dir: pathlib.Path)[source]¶
Load
src/widgets/<name>.pywithout allowing paths to escape it.- widgets_dir¶
- resolve(name: str) httk.serve.web.widgets.core.Widget | None[source]¶
- exception httk.serve.web.widgets.OptimadeTableProtocolError[source]¶
Bases:
ValueErrorA declared OPTIMADE table shell cannot meet the browser protocol.