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: ...,
auto_close=True, # auto call `close()` on the value after responsed
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.0.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for bottle_argsmap-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66d3b5e2f8bd39512c52bff732a8056cf03bb2cf3ff9bdbcc859dc8ddadf5d5a |
|
MD5 | 5fbb20b748e1108fee12a03efa3405da |
|
BLAKE2b-256 | 3e3939b34bdce4176b53679fb356da81dbc9306af6ef1e48a336a487785fc4e4 |