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, 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.0.tar.gz (27.9 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.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dishka_pyramid-1.0.0.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.0.tar.gz
Algorithm Hash digest
SHA256 710b29c3352a2015977467c53a3809febffed2faf444fd96fc30cc6e5a1682d8
MD5 2cf762776ab4eadb8ad11e17e51f622d
BLAKE2b-256 32f8d3bb937cc2f2d4ad9af7326e26ef6397c2be5dd4aca3492430115ed24807

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dishka_pyramid-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8791230d003af372ce4ef215775efb0521f89774402c67116154a414e29f1a1
MD5 7d832d8f9269a8e61f4e33a3376d753b
BLAKE2b-256 98400574328ac942a40bd9ccdcbf64e4d70974c1bacf7be7d9cf8a4bc219955b

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