Skip to main content

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


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 hashes)

Uploaded Source

Built Distribution

bottle_argsmap-0.1.1-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page