pyramid_blacksmith

class pyramid_blacksmith.PyramidBlacksmith(request: Request, clients: dict[str, SyncClientFactory[Any]], middleware_factories: dict[str, list[AbstractMiddlewareFactoryBuilder]])

Type of the request.blacksmith property.

This can be used to create a Protocol of the pyramid Request in final application for typing purpose.

Example:

from pyramid_blacksmith import PyramidBlacksmith

class RequestProtocol(Protocol):
    blacksmith: PyramidBlacksmith


def my_view(request: RequestProtocol):
    ...
__getattr__(name: str) Callable[[str], SyncClient[Any]]

Return the blacksmith client factory named in the configuration.

pyramid_blacksmith.includeme(config: Configurator)

Expose the method consume by the Configurator while using:

config.include('pyramid_blacksmith')

This will inject the request property request.blacksmith like the pyramid view below:

def my_view(request):

    api = request.blacksmith.client("api")
    ...
class pyramid_blacksmith.AbstractMiddlewareBuilder(settings: Mapping[str, str], prefix: str, metrics: PrometheusMetrics)
abstract build() SyncHTTPMiddleware

Build the Middleware

class pyramid_blacksmith.AbstractMiddlewareFactoryBuilder

Build the factory

abstract __call__(request: Request) SyncHTTPMiddleware

Called on demand per request to build a client with this middleware