Quack Quack: A simple application framework
Project description
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) to get those data.
For example, normally you would need to use two separate mechanism for settings in celery application and web application, because you should not use web application startup process in the celery app. This package provide a solution for this problem, by giving one simple and independent of other frameworks mechanism to implement everywhere.
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” the application. After that you can use the configurator as context manager.
from qq import Application, Context, InjectApplication, SimpleInjector
from qq.plugins import SettingsPlugin
from qq.plugins.types import Settings
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"])
@InjectApplication(application)
def samplefun(settings: Settings = SimpleInjector("settings")):
print(settings)
context.settings in above example is variable made by the SettingsPlugin. If you would like to know more, please go to the Tutorial
Installation
pip install quackquack
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for quackquack-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfd75b40632f38bc1d71864da45a765de0f5beaf206ff20d70f399f7d78f2410 |
|
MD5 | 1b6f30d0fea35e47a510cde5e7741c19 |
|
BLAKE2b-256 | 6e77c094e4d35ae3f465466d63d627499a7cb37580b9a6c0b891b103a5d2c42c |