Skip to content

jmaple.context

The per-invocation MethodContext passed to every method handler. Carries the authenticated principal, the database session, runtime settings, the capability registry, and helpers for bumping state strings and tracking created ids.

MethodContext dataclass

Per-invocation context — one instance per method call within a batch.

state_changes class-attribute instance-attribute

state_changes: dict[tuple[str, str], str] = field(
    default_factory=dict
)

(account_id, data_type) → new state string; harvested by the dispatcher.

bump_state async

bump_state(account_id: str, data_type: str) -> str

Atomically increment and return the new state string.

Also records the bump so the dispatcher can fan it out as a StateChange to the push broker after the request completes.

require_account

require_account(account_id: str) -> AccessibleAccount

Return the accessible :class:AccessibleAccount or raise accountNotFound.

require_capability

require_capability(urn: str) -> None

Raise forbidden if the request didn't declare this capability in using.