pyramid_blacksmith¶
- class pyramid_blacksmith.AbstractMiddlewareBuilder(settings: Mapping[str, str], prefix: str, metrics: PrometheusMetrics)¶
- abstractmethod build() SyncHTTPMiddleware¶
Build the Middleware
- class pyramid_blacksmith.AbstractMiddlewareFactoryBuilder(**kwargs: dict[str, bool])¶
Build the factory
- abstractmethod __call__(request: Request) SyncHTTPMiddleware¶
Called on demand per request to build a client with this middleware
- 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
Protocolof the pyramidRequestin 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.blacksmithlike the pyramid view below:def my_view(request): api = request.blacksmith.client("api") ...