A Flexible Service Locator for Pyramid
Project description
svcs Integration for Pyramid.
svcs-pyramid is the svcs integration for Pyramid.
svcs (pronounced services) is a dependency container for Python. It gives you a central place to register factories for types/interfaces and then imperatively acquire instances of those types with automatic cleanup and health checks.
svcs-pyramid wires that up for Pyramid: it stores the svcs registry in Pyramid's own registry (yes, unfortunate name clash) and uses a tween to attach a fresh container to every request – and to close it when the request is done.
import svcs_pyramid
def make_app():
with Configurator(settings=settings) as config:
svcs_pyramid.init(config)
svcs_pyramid.register_factory(config, Database, db_factory)
return config.make_wsgi_app()
@view_config(route_name="index")
def view(request):
db, api, cache = svcs_pyramid.get(request, Database, WebAPIClient, Cache)
To a type checker, db has the type Database, api has the type WebAPIClient, and cache has the type Cache.
db, api, and cache will be automatically cleaned up when the request ends – it's context managers all the way down.
Read on in svcs's Why? if you're intrigued.
Project links
Release Information
Deprecated
svcs_pyramid.get_abstract()is carried over fromsvcs.pyramidso that the rename is the only change you have to make, but it's deprecated. Thanks to PEP 747,svcs_pyramid.get()does the same thing. There are no deprecation warnings or plans to remove it for now.
Added
- Initial release.
svcs-pyramid is the extraction of svcs's
svcs.pyramidmodule into its own package.
Changed
-
The import name is
svcs_pyramidinstead ofsvcs.pyramid. Nothing else changed, so migrating is a pure rename:import svcs → import svcs_pyramid svcs.pyramid.init(…) → svcs_pyramid.init(…)The registry and the container are still stored under the
svcs_registryandsvcs_containerkeys, sosvcs_pyramidis a drop-in replacement forsvcs.pyramid.
Credits
svcs-pyramid is written by Hynek Schlawack and distributed under the terms of the MIT license.
It started out as the svcs.pyramid module inside of svcs and has been extracted into its own package.
The development is kindly supported by my employer Variomedia AG and all my fabulous GitHub Sponsors.
The Bestagon radar logo is made by Lynn Root, based on a Font Awesome icon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file svcs_pyramid-26.1.0.tar.gz.
File metadata
- Download URL: svcs_pyramid-26.1.0.tar.gz
- Upload date:
- Size: 148.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
931c87cf8231fccbc4e828fd13adcd4b00a71b9d0f1a3dc43f11d2a762ffcada
|
|
| MD5 |
6a1cb1846c4d06debbe98aed1d65b9eb
|
|
| BLAKE2b-256 |
bb2bf86d51b3a0c4de8093633c3d3bdea16076209f90afd48306c0add4ec9b5f
|
Provenance
The following attestation bundles were made for svcs_pyramid-26.1.0.tar.gz:
Publisher:
pypi-package.yml on hynek/svcs-pyramid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svcs_pyramid-26.1.0.tar.gz -
Subject digest:
931c87cf8231fccbc4e828fd13adcd4b00a71b9d0f1a3dc43f11d2a762ffcada - Sigstore transparency entry: 2255433411
- Sigstore integration time:
-
Permalink:
hynek/svcs-pyramid@67a04b1d711cc56204451f71a5b5b8b97b3c4de3 -
Branch / Tag:
refs/tags/26.1.0 - Owner: https://github.com/hynek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-package.yml@67a04b1d711cc56204451f71a5b5b8b97b3c4de3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file svcs_pyramid-26.1.0-py3-none-any.whl.
File metadata
- Download URL: svcs_pyramid-26.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80b8c29624bd59967accedec1e837c83c481afcfb7e459ca78560b662ffce086
|
|
| MD5 |
02e7e6b68d987d7cf9cde42b92950ee3
|
|
| BLAKE2b-256 |
b29c04d086e169f59b6cdb5c76f725868dfe0dca2f74a5828fb4d36a8654fff9
|
Provenance
The following attestation bundles were made for svcs_pyramid-26.1.0-py3-none-any.whl:
Publisher:
pypi-package.yml on hynek/svcs-pyramid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svcs_pyramid-26.1.0-py3-none-any.whl -
Subject digest:
80b8c29624bd59967accedec1e837c83c481afcfb7e459ca78560b662ffce086 - Sigstore transparency entry: 2255433434
- Sigstore integration time:
-
Permalink:
hynek/svcs-pyramid@67a04b1d711cc56204451f71a5b5b8b97b3c4de3 -
Branch / Tag:
refs/tags/26.1.0 - Owner: https://github.com/hynek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-package.yml@67a04b1d711cc56204451f71a5b5b8b97b3c4de3 -
Trigger Event:
release
-
Statement type: