pyramid_blacksmith#

class pyramid_blacksmith.PyramidBlacksmith(request: pyramid.request.Request, clients: Dict[str, blacksmith.service._sync.client.SyncClientFactory[Any]], middleware_factories: Dict[str, List[pyramid_blacksmith.middleware_factory.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], blacksmith.service._sync.client.SyncClient[Any]]#

Return the blacksmith client factory named in the configuration.

pyramid_blacksmith.includeme(config: pyramid.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: blacksmith.domain.model.middleware.prometheus.PrometheusMetrics)#
abstract build() blacksmith.middleware._sync.base.SyncHTTPMiddleware#

Build the Middleware

class pyramid_blacksmith.AbstractMiddlewareFactoryBuilder#

Build the factory

abstract __call__(request: pyramid.request.Request) blacksmith.middleware._sync.base.SyncHTTPMiddleware#

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