No project description provided
Project description
bottle_argsmap
Auto inject arguments via a dict
like pattern.
Usage
from bottle import Bottle
from bottle_argsmap import ArgsMapPlugin
app = Bottle()
plugin = try_install(app)
# inject via singleton
plugin.set_value('value', '1544')
# or inject via factory, dynamic creation is allowed
# e.g. you can to inject database connection from a database pool
plugin.set_factory('value',
lambda param_name, route: ...,
context_manager=True, # auto call `__exit__` on the value after responsed
)
# finally, inject it
@app.get('/path')
def get_it(value): # value is injected
return dict(value=value)
More
ArgsMapPlugin().ioc
is a instance of type anyioc.ServiceProvider
, which means you can use all features from anyioc
.
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
bottle-argsmap-0.1.1.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file bottle-argsmap-0.1.1.tar.gz
.
File metadata
- Download URL: bottle-argsmap-0.1.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.9.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d257f7d250c855b9df75cdd450e4153956c537e697a8846e834dbe5e8363c5a4 |
|
MD5 | 6192c2142dc87c55197ebd6dba659187 |
|
BLAKE2b-256 | 10fdd38a2d78aef064327f0b5f3749118c9ee4752463e02f90ccb9b87fd86d01 |
File details
Details for the file bottle_argsmap-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: bottle_argsmap-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.9.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14954e10d8be0a275f3f6ec571fa7421abda796e7151de4adeee44fee832c90c |
|
MD5 | 641ccb85fab2fcca1e5352d8a29a98ef |
|
BLAKE2b-256 | 67982859e55e680620adb9ae1ccaab7998ad0ccc1e5ec97593f752a6cb059fe1 |