The request scope is not available in scripts etc.
This removes current_app.test_request_context() from something like:
from flask import current_app
from postgresql_audit.flask import activity_values
with current_app.test_request_context(), activity_values(some='value'):
...
Previously, the activity_values(some='value') would do nothing if there was no request context.
I also refactored the code to remove has_request_context. That is safe as documented by flask.has_request_contextdocumentation.
flask.g is bound to application context (documentation)
BREAKING CHANGE: activity_values is set in more cases than before.
To be exact, the activity_values is also set when request context is not available,
but the application context is.
The request scope is not available in scripts etc.
This removes
current_app.test_request_context()
from something like:Previously, the
activity_values(some='value')
would do nothing if there was no request context.I also refactored the code to remove
has_request_context
. That is safe as documented byflask.has_request_context
documentation.flask.g
is bound to application context (documentation)BREAKING CHANGE: activity_values is set in more cases than before. To be exact, the activity_values is also set when request context is not available, but the application context is.