# bottle-utils
Reusable components for bottle
## Responses
### Plugin response.JsonResponsePlugin
The JSON response plugin is a plugin that provides three main features:
Returns dict or list responses as a JSON object: {“result”: <output>} * If the response is a dict containing either “result” or “error”, the result is returned as-is
Catches HTTPResponse exceptions (including the subclass HTTPError) and formats them as a JSON object: {“error”: {“code”: <http response code>, “message”: <exception message>}}
Provides an error handler that can be used to replace the standard error handler with one that returns JSON objects * The handler must be manually applied for each error code to each app, except as shown below
## SQLAlchemy
The SQLAlchemy package must be installed, and is NOT a requirement of this package as a whole! Make sure it is installed or ImportError will be raised.
### Plugin sqlalchemy.SQLAlchemyNotFoundPlugin
The SQLAlchemy not found plugin converts SQLAlchemy not found exceptions to 404s. Apply within the JsonResponsePlugin to turn not found objects into a nicely formatted JSON error message.
### Plugin sqlalchemy.SQLAlchemySession
Given an sqlalchemy engine in the constructor, this plugin creates bottle.request.sa_session that can be used for querying. This results in a new session for each thread/request. The kwarg “autocommit” may also be passed, turning automatic commits on or off (default: True)
## Apps
### Function apps.setup
Set up a collection of apps. The function accepts the following arguments:
main_app (required): “main” app on which other apps are mounted
sub_apps (optional): List containing either plain application instances (which are not mounted anywhere) or lists containing [app, mountpoint], where the app is mounted to main_app at mountpoint. The main_app is automatically added to this list - do not add it yourself.
plugins (optional): list of plugins to install to all apps
error_handlers (optional): List containing either error handler callbacks, or lists containing [range, handler] where handler is applied to all error codes in range (default range is 300-599)
error_handler_generators (optional): List containing either methods that generate error handler callbacks, or lists containing [range, handler_generator] where handler_generator(code) is applied to all error codes in range (default range is 300-599)
- error_handler_generators can be used to apply the JSON response error handler:
setup(mainapp, [otherapp], error_handler_generators = [JsonResponsePlugin.getErrorHandler])
Metadata
Release files for bottleutils 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bottleutils-0.1.5.tar.gz | 4.4 kB | Without provenance | Details for bottleutils-0.1.5.tar.gz |
Release files / bottleutils-0.1.5.tar.gz
| Download URL | bottleutils-0.1.5.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c0f7183674f9662c14932c382680ce1f365c47365035ce47216288ffbad7660
|
|
BLAKE2b-256 checksum How to use checksums |
a5582475fec4042d1868b71b063aaaf435a08b56f4ae18188fe06f79b5ceadff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for bottleutils 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.