All Projects → meadsteve → Lagom

meadsteve / Lagom

Licence: mit
📦 Autowiring dependency injection container for python 3

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects
types
53 projects

Projects that are alternatives of or similar to Lagom

Python Articles
Monthly Series - Top 10 Python Articles
Stars: ✭ 288 (+372.13%)
Mutual labels:  django, flask
Pygmy
An open-source, feature rich & extensible url-shortener + analytics written in Python 🍪
Stars: ✭ 569 (+832.79%)
Mutual labels:  django, flask
Turkce Python Kaynaklari
Türkçe olarak hazırlanmış Python programlama dili ile ilgili içeriklerin derlendiği sayfa.
Stars: ✭ 295 (+383.61%)
Mutual labels:  django, flask
Cancan
cancan is a tiny permission controller base on ruby cancan library.
Stars: ✭ 244 (+300%)
Mutual labels:  django, flask
Heroku Buildpack Python
The official Heroku buildpack for Python apps.
Stars: ✭ 849 (+1291.8%)
Mutual labels:  django, flask
Zappa
Serverless Python
Stars: ✭ 224 (+267.21%)
Mutual labels:  django, flask
Minimal Django
A lightweight Django project - because Django can be nearly as simple as a microframework
Stars: ✭ 490 (+703.28%)
Mutual labels:  django, flask
Pyrollbar
Error tracking and logging from Python to Rollbar
Stars: ✭ 169 (+177.05%)
Mutual labels:  django, flask
Mixer
Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.
Stars: ✭ 743 (+1118.03%)
Mutual labels:  django, flask
Chartkick.py
Create beautiful Javascript charts with minimal code
Stars: ✭ 695 (+1039.34%)
Mutual labels:  django, flask
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+4578.69%)
Mutual labels:  django, flask
Channelstream
Channelstream is a websocket communication server for web applications
Stars: ✭ 52 (-14.75%)
Mutual labels:  django, flask
Bolt Python
A framework to build Slack apps using Python
Stars: ✭ 190 (+211.48%)
Mutual labels:  django, flask
Admin Dashboards
Admin Dashboards - Open-Source and Free | AppSeed
Stars: ✭ 275 (+350.82%)
Mutual labels:  django, flask
Flango
A Django template for using Flask for the frontend, Django for the backend.
Stars: ✭ 188 (+208.2%)
Mutual labels:  django, flask
Apm Agent Python
Official Python agent for the Elastic APM
Stars: ✭ 301 (+393.44%)
Mutual labels:  django, flask
Bento
[DEPRECATED] Find Python web-app bugs delightfully fast, without changing your workflow. 🍱
Stars: ✭ 147 (+140.98%)
Mutual labels:  django, flask
Zappa
Serverless Python
Stars: ✭ 11,859 (+19340.98%)
Mutual labels:  django, flask
Python24
网上搜集的自学python语言的资料集合,包括整套代码和讲义集合,这是至今为止所开放网上能够查找到的最新视频教程,网上找不到其他最新的python整套视频了,. 具体的无加密的mp4视频教程和讲义集合可以在更新的Readme文件中找到,下载直接打开就能播放,项目从零基础的Python教程到深度学习,总共30章节,其中包含Python基础中的飞机大战项目,WSGI项目,Flask新经资讯项目, Django的电商项目(本应该的美多商城项目因为使用的是Vue技术,所以替换为Django天天生鲜项目)等等,希望能够帮助大家。资源搜集劳神费力,能帮到你的话是我的福分,望大家多多支持,喜欢本仓库的话,记得Star哦。
Stars: ✭ 650 (+965.57%)
Mutual labels:  django, flask
Yesterday I Learned
Brainfarts are caused by the rupturing of the cerebral sphincter.
Stars: ✭ 50 (-18.03%)
Mutual labels:  django, flask

Lagom

Scrutinizer Code Quality Code Coverage PyPI Downloads

What

Lagom is a dependency injection container designed to give you "just enough" help with building your dependencies. The intention is that almost all of your code doesn't know about or rely on lagom. Lagom will only be involved at the top level to pull everything together.

Features

  • Typed based auto wiring with zero configuration.
  • Fully based on types. Strong integration with mypy.
  • Minimal changes to existing code.
  • Integration with a few common web frameworks.
  • Support for async python.
  • Thread-safe at runtime

You can see a comparison to other frameworks here

Installation

pip install lagom
# or: 
# pipenv install lagom
# poetry add lagom

Note: if you decide to clone from source then make sure you use the latest version tag. The master branch may contain features that will be removed.

For the versioning policy read here: SemVer in Lagom

Usage

Everything in Lagom is based on types. To create an object you pass the type to the container:

container = Container()
some_thing = container[SomeClass]

Auto-wiring (with zero configuration)

Most of the time Lagom doesn't need to be told how to build your classes. If the __init__ method has type hints then lagom will use these to inject the correct dependencies. The following will work without any special configuration:

class MyDataSource:
    pass
    
class SomeClass:
   def __init__(datasource: MyDataSource)
      pass

container = Container()
some_thing = container[SomeClass] # An instance of SomeClass will be built with an instance of MyDataSource provided

and later if you extend your class no changes are needed to lagom:

class SomeClass:
   def __init__(datasource: MyDataSource, service: SomeFeatureProvider)
      pass

# Note the following code is unchaged
container = Container()
some_thing = container[SomeClass] # An instance of SomeClass will be built with an instance of MyDataSource provided

Singletons

You can tell the container that something should be a singleton:

container[SomeExpensiveToCreateClass] = SomeExpensiveToCreateClass("up", "left")

Explicit build instructions when required

You can explicitly tell the container how to construct something by giving it a function:

container[SomeClass] = lambda: SomeClass("down", "spiral")

All of this is done without modifying any of your classes. This is one of the design goals of lagom.

Hooks in to existing systems

A decorator is provided to hook top level functions into the container.

@bind_to_container(container)
def handle_move_post_request(request: typing.Dict, game: Game = lagom.injectable):
    # do something to the game
    return Response()

(There's also a few common framework integrations provided here)

Full docs here here

Contributing

Contributions are very welcome. Please see instructions here

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].