Metadata-Version: 2.4
Name: svcs-pyramid
Version: 26.1.0
Summary: A Flexible Service Locator for Pyramid
Project-URL: Changelog, https://github.com/hynek/svcs-pyramid/blob/main/CHANGELOG.md
Project-URL: Documentation, https://svcs-pyramid.readthedocs.io/
Project-URL: GitHub, https://github.com/hynek/svcs-pyramid
Project-URL: Funding, https://github.com/sponsors/hynek
Project-URL: Mastodon, https://mastodon.social/@hynek
Project-URL: Twitter, https://twitter.com/hynek
Author-email: Hynek Schlawack <hs@ox.cx>
License-Expression: MIT
License-File: LICENSE
Keywords: dependency injection,inversion of control,pyramid,service locator
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Pyramid
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: pyramid
Requires-Dist: svcs>=26.1.0
Requires-Dist: typing-extensions>=4.13.0; python_version < '3.15'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://github.com/hynek/svcs-pyramid/"><img src="https://raw.githubusercontent.com/hynek/svcs-pyramid/main/docs/_static/logo_with_name.svg" width="35%" alt="svcs logo showing a hexagon-shaped radar" /></a>
  <a href="https://trypyramid.com"><img src="https://raw.githubusercontent.com/hynek/svcs-pyramid/main/docs/_static/pyramid_logo.png" width="35%" alt="Pyramid logo" /></a>
</p>

<p align="center">
  <em>svcs Integration for Pyramid.</em>
</p>
<!-- begin index -->

*svcs-pyramid* is the [*svcs*](https://svcs.hynek.me/) integration for [Pyramid](https://trypyramid.com).

*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](https://docs.pylonsproject.org/projects/pyramid/en/main/glossary.html#term-tween) to attach a fresh container to every request – and to close it when the request is done.

<!-- end index -->

<!-- skip: next -->

```python
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)
```

<!-- begin addendum -->
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.
<!-- end addendum -->

Read on in [*svcs*'s *Why?*](https://svcs.hynek.me/en/stable/why.html) if you're intrigued.


## Project links

- [***svcs* itself**](https://github.com/hynek/svcs)
- [**PyPI**](https://pypi.org/project/svcs-pyramid/)
- [**GitHub**](https://github.com/hynek/svcs-pyramid)
- [**Documentation**](https://svcs-pyramid.readthedocs.io/)
- [**Changelog**](https://github.com/hynek/svcs-pyramid/blob/main/CHANGELOG.md)
- [**Funding**](https://hynek.me/say-thanks/)

## 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.

[PEP 747]: https://peps.python.org/pep-0747/


### 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 →](https://github.com/hynek/svcs-pyramid/blob/main/CHANGELOG.md)


## Credits

*svcs-pyramid* is written by [Hynek Schlawack](https://hynek.me/) and distributed under the terms of the [MIT](https://github.com/hynek/svcs-pyramid/blob/main/LICENSE) license.

It started out as the `svcs.pyramid` module inside of [*svcs*](https://github.com/hynek/svcs) and has been extracted into its own package.

The development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/) and all my fabulous [GitHub Sponsors](https://github.com/sponsors/hynek).

The [Bestagon](https://www.youtube.com/watch?v=thOifuHs6eY) radar logo is made by [Lynn Root](https://www.roguelynn.com), based on a [Font Awesome](https://fontawesome.com) icon.
