Skip to main content

deed - Python

ActivityFormatter for object changes (auditlog)

Usage

Try it on your python console:

from deed import AuditLog, AuditMode

# stored resource
resource = {'_id': '123', 'user_id': '123',
            'customer_id': '123',
            'title': "My amazing post"}
refs = [  # stakeholders
    'post:' + resource['_id'],
    'owner:' + resource['user_id'],
    'customer:' + resource['customer_id'],
]

# update example
audit_log = AuditLog(resource_type='shipment',
                     action='update', audit_mode=AuditMode.DIFF)
audit_log.session(actor='user:admin@example.com', where='10.0.0.2',
                  channel='edit-form', stakeholders=refs)

patch = {'title': 'My first post'}
new_resource = {**resource, **patch}
audit_log.audit(resource, payload=new_resource)

Bottle Integration

from bottle import run, request, Bottle
from deed import AuditMode
from deed.bottle_kit import audit, DeedPlugin

from business.models import Post

api = Bottle()
api.install(DeedPlugin())


@api.put('/post/<id:int>')
@audit(resource_type='post', action='update', audit_mode=AuditMode.DIFF)
def update_post(id: int):
    stored_post = Post.find(id)
    payload = request.json
    updated_post = {**stored_post, **payload}
    Post.update(updated_post)
    request.audit.session['actor'] = 'admin'  # authorized user
    request.audit.resource = stored_post
    request.audit.payload = updated_post
    return post


if __name__ == '__main__':
    run(api, port=8080)

Metadata

Release files for deed 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deed 0.1.6
File Size Uploaded Provenance Actions
deed-0.1.6.tar.gz 5.1 kB Without provenance Details for deed-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for deed 0.1.6
File Interpreter ABI Platform Actions
deed-0.1.6-py3-none-any.whl Python 3 none any Details for deed-0.1.6-py3-none-any.whl

Total release size: 11.3 kB

Release files / deed-0.1.6.tar.gz

Download URL deed-0.1.6.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b68341f971e1f5f215a84c855b56482f30c5fd2edd8d06be4a8971b8741e70e4
BLAKE2b-256 checksum
How to use checksums
e3f9c8ff1e1fafb8059137470923f875be03abef25676091e94feb4d561471cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.13

Release files / deed-0.1.6-py3-none-any.whl

Download URL deed-0.1.6-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32fcc836f00c565268c3f970f12704b1df96392ab25dbf5520ee7b970c1dd59a
BLAKE2b-256 checksum
How to use checksums
3c5bb9638f7c89f88a394622a3bbbd0dbbe7b2c9275931ab288c76bd47d5fd89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.13

Security for deed 0.1.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page