AUDIT FOR SQLAlchemy and Mongoengine
Library for auditing models made with SQLAlchemy and Mongoengine. This library exposes a signal which you can use to add your custom method.
Instalation
Use following command:
pip install package-audit-flask
Usage
This library exposes a signal which you can use to add your custom method, this method receives kwargs where predefined arguments will arrive.
How is it used in SQLAlchemy?
Import library and then "Register" your model using the keep_logs_models method, as follows:"
from fk_audit_flask.audit.sqlalchemy import sqlalchemy
class Model:
...
sqlalchemy.keep_logs_models(Model)
Then, conect the "signal" signal with your custom method
def custom_method(*args, **kwargs):
...
sqlalchemy.signal.connect(custom_method)
Kwargs in your custom method
If SETTINGS.HEADERS = FALSE
| Name | Type | Desciption |
|---|---|---|
| object_pk | int | Primary key |
| content_type | str | Name of the table or collection |
| object_repr | dict | Object in dictionary after changes |
| action | str | It can be any of the following options ['create', 'delete', 'update'] |
| changes | str | Object changes |
| object_before_changed | dict | Object in dictionary before changes |
If SETTINGS.HEADERS = True
Same as above, with two additional keys.
| Name | Type | Desciption |
|---|---|---|
| remote_addr | dict | Corresponds to the headers of the request made |
| user | str | Dictionary with the keys assigned in SETTINGS.USER_VALIDATE_HEADERS |
Additional configuration
- If you have a key that you need to extract for the user kwargs, add the keys in the
SETTINGS.USER_VALIDATE_HEADERSconfiguration by default you have assigned:['X-User-Id', 'X-Auth-User-Id']. - If you do not want to get the kwargs remote_addr and user, asgine
SETTINGS.HEADERS = False
Dependencies
- flask>=2.2.5 # If SETTINGS.HEADERS = True, deafult is True
- blinker>=1.4
- mongoengine>=0.23.1
- sqlalchemy>=1.4.52
License
Authors
Release files for fk-audit-flask 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fk_audit_flask-0.1.7.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fk_audit_flask-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / fk_audit_flask-0.1.7.tar.gz
| Download URL | fk_audit_flask-0.1.7.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32a2c8ab64d35101388de7a768721d1edc75199083b2d17dd1f3b57e9ead9a79
|
|
BLAKE2b-256 checksum How to use checksums |
683bc6378e0275055834c78dda81e0c388cb23b60d7bccbb5eadf96517fe32b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.13.15 Linux/6.17.0-1022-azure
|
Release files / fk_audit_flask-0.1.7-py3-none-any.whl
| Download URL | fk_audit_flask-0.1.7-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
314af1de3009028851736cd2ca7c2f306617cfe8749d0c1d5e545403378df657
|
|
BLAKE2b-256 checksum How to use checksums |
3d38457b8b420a7c0023a13fafc3d2042c168d323d261e4b4577f211ca3063f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.13.15 Linux/6.17.0-1022-azure
|