ploneasgi.app#
Compose the ASGI application.
The whole extension story is create_app()'s keyword arguments. There is
deliberately no registration framework, no entry-point scanning and no
middleware registry: the moment this grows one, PasteDeploy has been reinvented
with extra steps. Adding a route means passing a route.
ploneasgi.zcml lets an add-on declare a route — it has no server.py
to edit — but nothing here looks for them. The project calls
ploneasgi.zcml.routes_from_registry() and passes the result to routes,
so this function still only ever sees a list someone handed it.
- ploneasgi.app.LifespanFactory#
Signature of a lifespan factory: called with the app, used as a context manager for the lifetime of the server. What
@asynccontextmanagerreturns — not the bare async generator underneath it.alias of
Callable[[Any],AbstractAsyncContextManager[None]]
- ploneasgi.app.AdapterFactory#
Builds the ASGI app that mounts a WSGI app; see
default_adapter().alias of
Callable[[Callable[[...],Iterable[bytes]],Settings],Callable[[MutableMapping[str,Any],Callable[[],Awaitable[MutableMapping[str,Any]]],Callable[[MutableMapping[str,Any]],Awaitable[None]]],Awaitable[None]]]
- ploneasgi.app.default_adapter(wsgi_app, settings)[source]#
Wrap a WSGI app in this package's adapter.
- Parameters:
- Returns:
The configured adapter.
- Return type:
- ploneasgi.app.create_app(settings=None, *, routes=(), middleware=(), lifespans=(), wsgi_app=None, adapter=None)[source]#
Build the Starlette application with Zope mounted at
/.- Parameters:
settings (Settings | None) -- Settings to use; read from the environment when omitted.
routes (Sequence[BaseRoute]) -- Extra routes, matched before the catch-all Zope mount. This is where websocket endpoints and native HTTP routes go.
middleware (Sequence[Middleware]) -- Starlette middleware wrapping the whole application, including the routes above. Access logging belongs here.
lifespans (Sequence[Callable[[Any], AbstractAsyncContextManager[None]]]) -- Extra lifespan context managers, entered after Zope's and exited before it, so they can rely on the ZODB being open.
wsgi_app (Callable[[...], Iterable[bytes]] | None) -- A prebuilt WSGI application; built from
settingswhen omitted. Useful in tests, where the layer already started Zope.adapter (Callable[[Callable[[...], Iterable[bytes]], Settings], Callable[[MutableMapping[str, Any], Callable[[], Awaitable[MutableMapping[str, Any]]], Callable[[MutableMapping[str, Any]], Awaitable[None]]], Awaitable[None]]] | None) -- Builds the ASGI app that wraps
wsgi_app; defaults toploneasgi.wsgi.WSGIMiddleware. This package's central claim is that its adapter beatsa2wsgi, so the seam to swap one in and check is deliberate — a claim nobody can falsify is not worth much.
- Returns:
The composed Starlette application.
- Return type:
Starlette