httk.serve.web

Submodules

Attributes

SITE_RESOURCES_KEY

Stable global_data key through which site startup code gets resources.

Classes

ProviderContext

The immutable, site-local context passed to a table provider.

TableColumn

A table column and its small, presentation-only metadata.

TablePage

One provider-owned page of structured rows and opaque navigation cursors.

TableRequest

The bounded page request passed to provide(context, request, ...).

SiteResources

Callbacks owned by one httk.serve.web.engine.site_engine.SiteEngine.

Functions

create_asgi_app(→ starlette.applications.Starlette)

publish(→ httk.serve.web.model.page.PublishReport)

serve(→ None)

Package Contents

httk.serve.web.create_asgi_app(srcdir: str | pathlib.Path, *, baseurl: str | None = None, compatibility_mode: bool = False, config_name: str = 'config', debug: bool = False, table_token_secret: str | bytes | None = None) starlette.applications.Starlette[source]
httk.serve.web.publish(srcdir: str | pathlib.Path, outdir: str | pathlib.Path, baseurl: str, *, host_static: str | None = None, compatibility_mode: bool = False, config_name: str = 'config', use_urls_without_ext: bool | None = None) httk.serve.web.model.page.PublishReport[source]
httk.serve.web.serve(srcdir: str | pathlib.Path, *, host: str = '127.0.0.1', port: int = 8080, baseurl: str | None = None, compatibility_mode: bool = False, config_name: str = 'config', debug: bool = False, table_token_secret: str | bytes | None = None) None[source]
class httk.serve.web.ProviderContext[source]

The immutable, site-local context passed to a table provider.

route: str
widget_id: str
query: collections.abc.Mapping[str, str]
page: collections.abc.Mapping[str, object]
global_data: collections.abc.Mapping[str, object]
url_for(route: str, *, query: collections.abc.Mapping[str, str] | None = None) str[source]

Build a site-local route URL without exposing the ASGI request.

class httk.serve.web.TableColumn[source]

A table column and its small, presentation-only metadata.

key: str
label: str
align: str | None = None
class_name: str | None = None
classmethod from_value(value: Self | str | collections.abc.Mapping[str, object]) Self[source]

Adapt the compact forms useful in small, site-local providers.

class httk.serve.web.TablePage[source]

One provider-owned page of structured rows and opaque navigation cursors.

rows: tuple[collections.abc.Mapping[str, object], Ellipsis]
columns: tuple[TableColumn, Ellipsis]
next_cursor: str | None = None
previous_cursor: str | None = None
total: int | None = None
revision: str | None = None
classmethod from_rows(rows: collections.abc.Iterable[collections.abc.Mapping[str, object]], *, columns: collections.abc.Iterable[TableColumn | str | collections.abc.Mapping[str, object]], next_cursor: str | None = None, previous_cursor: str | None = None, total: int | None = None, revision: str | None = None) Self[source]

Construct a page while adapting compact column declarations.

classmethod from_result(value: object) Self[source]

Accept a TablePage or the equivalent explicit mapping.

class httk.serve.web.TableRequest[source]

The bounded page request passed to provide(context, request, ...).

page_size: int = 50
cursor: str | None = None
revision: str | None = None
httk.serve.web.SITE_RESOURCES_KEY = 'httk_serve_resources'[source]

Stable global_data key through which site startup code gets resources.

class httk.serve.web.SiteResources[source]

Callbacks owned by one httk.serve.web.engine.site_engine.SiteEngine.

Site functions/init.py code can obtain this object from global_data[SITE_RESOURCES_KEY] and call register() for every persistent resource it opens. Callbacks run in reverse registration order when the httk.serve.web.engine.site_engine.SiteEngine closes. Closing is idempotent, so ASGI lifespan shutdown and an enclosing helper may both safely close the same engine.

property closed: bool

Whether cleanup has started for this registry.

register(callback: CleanupCallback) None[source]

Register one synchronous callback to run during close().

Registration after close is a programming error: the callback could no longer be guaranteed to run.

close() None[source]

Run pending callbacks in LIFO order exactly once.

Every callback gets a chance to run. If cleanup fails, the first exception is re-raised after the remaining callbacks have executed; additional failures are attached as notes for diagnosis.