Skip to main content

Quack Quack: A simple application initializator

Project description

Documentation

Overview

This project aims to resolve problem of configuring an application, which needs to have initialization step (for example: for gathering settings or establishing connections) and use Python style code (context managers and decorators) with dependency injection to get those data.

For example, normally you would need to use two separate mechanism for connection to the database (one for web, and one for celery). Mostly it uses the web framework configuration, to use in the celery code. It is fine, until a third sub-application arrives. Or you have many microservices, where web frameworks are different depending on the microservice purpose.

Second goal was to make synchronized code without any globals or magic. That is why using Quack Quack you know when the application is initialized (started), or where to look for code you are using.

In order to use QQ, you don’t need to use hacks in some starting files, like importing something from django, starting the application, and the import the rest.

Quick Using Example

To use Quack Quack you need to create the application class (inherited from qq.Application) in which you need to add plugins. After configuring, you need to “start” (initialize) the application. After that you can use the application as context manager. Also, you can make simple decorator, so you can use injectors (dependency injection) in function’s arguments.

from qq import Application
from qq import Context
from qq import SimpleInjector
from qq.plugins import SettingsPlugin
from qq.plugins.types import Settings
from qq.injectors import SetApplication
from qq.injectors import SetInjector


class MyApplication(Application):
    def create_plugins(self):
        self.plugins["settings"] = SettingsPlugin("settings")


application = MyApplication()
application.start("application")

with Context(application) as ctx:
    print(ctx["settings"])

app = SetApplication(application)


@app
@SetInjector("settings", SimpleInjector("settings"))
def samplefun(settings: Settings):
    print(settings)


samplefun()
samplefun({"info": "fake settings"})  # dependency injection !!

context["settings"] in above example, is a variable made by the SettingsPlugin. If you would like to know more, please go to the Tutorial

Installation

pip install quackquack

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

quackquack-1.3.3.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

quackquack-1.3.3-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file quackquack-1.3.3.tar.gz.

File metadata

  • Download URL: quackquack-1.3.3.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-arch1-1

File hashes

Hashes for quackquack-1.3.3.tar.gz
Algorithm Hash digest
SHA256 ab4f89e2749231edb2450301efb4e43971e9334be607e24ae611fbd6180eb6c3
MD5 a907a0f75ff4d0c97ab9456b8737365e
BLAKE2b-256 85df0f4bddc779c79c9287f4bbc7b95ea91d3827e13d75cdf51404b24ba57888

See more details on using hashes here.

File details

Details for the file quackquack-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: quackquack-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-arch1-1

File hashes

Hashes for quackquack-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7ec9cedc1ec6033532115fe4510fb47ef632fa7cdeb3d37c6df2a727250c9f21
MD5 07238c2e22012fa5db87d736fc0f7506
BLAKE2b-256 1e49d8926dcbfa4af4cc1e5e7364a5cd7aa0bacb964afb4af971697f0e2ab1be

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