Skip to main content

Dishka DI integration for Pyramid framework

Project description

Pyramid integration for Dishka

Dishka DI integration for the Pyramid framework.

Installation

via uv:

uv add dishka-pyramid

via pip:

pip install dishka-pyramid

Usage

Usage example

from typing import Final

from dishka import Provider, Scope, make_container, provide
from pyramid.config import Configurator
from pyramid.request import Request
from pyramid.response import Response
from pyramid.view import view_config

from dishka_pyramid import FromDishka, PyramidProvider, inject, setup_dishka


class GetHelloInteractor:
    def execute(self) -> str:
        return "Hello from Dishka!"


class MyProvider(Provider):
    @provide(scope=Scope.REQUEST)
    def get_hello_interactor(self) -> GetHelloInteractor:
        return GetHelloInteractor()


GET_HELLO_ROUTE_NAME: Final[str] = "hello"


@view_config(route_name=GET_HELLO_ROUTE_NAME)
@inject
def my_view(request: Request, interactor: FromDishka[GetHelloInteractor]) -> Response:
    response_text = interactor.execute()
    return Response(response_text)


container = make_container(PyramidProvider(), MyProvider())

config = Configurator()
setup_dishka(container=container, config=config)

config.add_route(name=GET_HELLO_ROUTE_NAME, pattern="/hello")
config.scan()

app = config.make_wsgi_app()

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

dishka_pyramid-1.0.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

dishka_pyramid-1.0.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file dishka_pyramid-1.0.1.tar.gz.

File metadata

  • Download URL: dishka_pyramid-1.0.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dishka_pyramid-1.0.1.tar.gz
Algorithm Hash digest
SHA256 112d4fa4ff674e934ff6ba8afdeec9945e181a9719c79271752bd1f251166fe7
MD5 8564e90896cfe002cfed3d7da6f3334a
BLAKE2b-256 6cf696bcea240f81121de27f361d5f3dba50ede0ace16515f7802f810f002fe3

See more details on using hashes here.

File details

Details for the file dishka_pyramid-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: dishka_pyramid-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dishka_pyramid-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e02e6e52a2af03c78300ac073d82950967d85d43b5ee068cac8e34c75f995570
MD5 2eaea9406414546895b8a948cc3c3c6d
BLAKE2b-256 0c0e64efb7d3d444dca9d7f971719b824601555857d60f583cb71b43fd761f43

See more details on using hashes here.

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