RequestContext

class gafaelfawr.dependencies.context.RequestContext(request, ip_address, config, logger, events, session, factory)

Bases: object

Holds the incoming request and its surrounding context.

The primary reason for the existence of this class is to allow the functions involved in request processing to repeated rebind the request logger to include more information, without having to pass both the request and the logger separately to every function.

Parameters:

Attributes Summary

config

Gafaelfawr's configuration.

events

Frontend events publishers.

factory

The component factory.

ip_address

IP address of client.

logger

The request logger, rebound with discovered context.

request

The incoming request.

session

The database session.

state

User cookie state.

Methods Summary

rebind_logger(**values)

Add the given values to the logging context.

Attributes Documentation

config: Config

Gafaelfawr’s configuration.

events: FrontendEvents

Frontend events publishers.

factory: Factory

The component factory.

ip_address: str

IP address of client.

logger: BoundLogger

The request logger, rebound with discovered context.

request: Request

The incoming request.

session: async_scoped_session

The database session.

state

User cookie state.

Methods Documentation

rebind_logger(**values)

Add the given values to the logging context.

Parameters:

**values (Any) – Additional values that should be added to the logging context.

Return type:

None