Skip to main content

Flask support for dependency injection with autoinject

Project description

Flask AutoInject

Flask integration to provide separate contexts for each request regardless of the underlying WSGI handler.

As of version 1.1.0, you MUST use the init_app() function to properly use autoinject with Flask contexts. Previously, the informant was registered automatically. Calling init_app() also registers a teardown_appcontext() callback which removes the application context.

Note that Flask calls functions registered via teardown_appcontext() from last to first. The call to flask_autoinject.init_app() should therefore go BEFORE any function which might also register an appcontext teardown that relies on an injected variable. Since request teardowns happen before appcontext teardowns, it is also safe to use injected objects in request teardown functions.

import flask
import flask_autoinject

app = flask.Flask(__name__)
flask_autoinject.init_app(app)

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

flask_autoinject-1.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

flask_autoinject-1.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file flask_autoinject-1.1.0.tar.gz.

File metadata

  • Download URL: flask_autoinject-1.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for flask_autoinject-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8231a37ececcd68e490e94e8269f4fb71f16015d24af61c8385e0c4a139e2349
MD5 cc00e310c2489c75ce6ab149d6b22b30
BLAKE2b-256 30c1bd1924afa2d703dc549bed6added2e8b744bdaf3bb05a4ec736baa534f3d

See more details on using hashes here.

File details

Details for the file flask_autoinject-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_autoinject-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f33ffe275aa7c173ecc5f04ff366b2a4a7b0eb14891b42c338416febaf51d388
MD5 09317254a5e1542e5a3a09b0dd60fb8d
BLAKE2b-256 6371201a9fc1360a2b72ca4356c3104c7c6e84cd14afbd2220b9ac01cc5241bc

See more details on using hashes here.

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