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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bottle-argsmap-0.1.0.tar.gz.
File metadata
- Download URL: bottle-argsmap-0.1.0.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 |
23f2a2178ab4f9bb4465ad4565a506ed1ed04cb92a4cf5c611f3c289dbc75b78
|
|
| MD5 |
c44e268c487da0e74e7465696c08fa55
|
|
| BLAKE2b-256 |
5927aa631be198a8233f0e43010977cebdc764580626bd6df91e1298cd62c304
|
File details
Details for the file bottle_argsmap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bottle_argsmap-0.1.0-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 |
66d3b5e2f8bd39512c52bff732a8056cf03bb2cf3ff9bdbcc859dc8ddadf5d5a
|
|
| MD5 |
5fbb20b748e1108fee12a03efa3405da
|
|
| BLAKE2b-256 |
3e3939b34bdce4176b53679fb356da81dbc9306af6ef1e48a336a487785fc4e4
|