httk.serve.web.widgets.loader

Safe loading and deterministic discovery of trusted site-local widgets.

Classes

SiteWidgetLoader

Load site widgets without allowing paths to escape their directory.

Module Contents

class httk.serve.web.widgets.loader.SiteWidgetLoader(widgets_dir)[source]

Load site widgets without allowing paths to escape their directory.

Parameters:

widgets_dir (pathlib.Path) – Directory containing trusted site widget modules.

widgets_dir[source]
available()[source]

List valid site-local widget modules.

Returns:

Sorted (name, source path) pairs.

Return type:

list[tuple[str, str]]

resolve(name)[source]

Resolve and load one site-local widget.

Parameters:

name (str) – Site widget name beginning with site..

Returns:

Loaded widget, or None when the name or file is absent.

Raises:

ValueError – If the widget module or definition is invalid.

Return type:

httk.serve.web.widgets.core.Widget | None