Skip to main content

A Flexible Service Locator for Pyramid

Project description

svcs logo showing a hexagon-shaped radar Pyramid logo

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 from svcs.pyramid so 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.pyramid module into its own package.

Changed

  • The import name is svcs_pyramid instead of svcs.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_registry and svcs_container keys, so svcs_pyramid is a drop-in replacement for svcs.pyramid.


Full Changelog →

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svcs_pyramid-26.1.0.tar.gz (148.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svcs_pyramid-26.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

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

Hashes for svcs_pyramid-26.1.0.tar.gz
Algorithm Hash digest
SHA256 931c87cf8231fccbc4e828fd13adcd4b00a71b9d0f1a3dc43f11d2a762ffcada
MD5 6a1cb1846c4d06debbe98aed1d65b9eb
BLAKE2b-256 bb2bf86d51b3a0c4de8093633c3d3bdea16076209f90afd48306c0add4ec9b5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for svcs_pyramid-26.1.0.tar.gz:

Publisher: pypi-package.yml on hynek/svcs-pyramid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for svcs_pyramid-26.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80b8c29624bd59967accedec1e837c83c481afcfb7e459ca78560b662ffce086
MD5 02e7e6b68d987d7cf9cde42b92950ee3
BLAKE2b-256 b29c04d086e169f59b6cdb5c76f725868dfe0dca2f74a5828fb4d36a8654fff9

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page