Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade EasyAuditMiddleware to support sync and async contexts. #291

Open
KaczuH opened this issue Apr 20, 2024 · 1 comment
Open

Upgrade EasyAuditMiddleware to support sync and async contexts. #291

KaczuH opened this issue Apr 20, 2024 · 1 comment

Comments

@KaczuH
Copy link

KaczuH commented Apr 20, 2024

EasyAuditMiddleware currently only supports synchronous code, requiring adaptations by Django for async operation.

As such, projects using easy audit cannot benefit from async stack as shown by the django.request logger:

DEBUG:django.request:Asynchronous handler adapted for middleware easyaudit.middleware.easyaudit.EasyAuditMiddleware.

Relevant Django documentation can be found in Django Docs:.

There is a potential simple fix: replacing threading.local with asgiref and using MiddlewareMixin.

KaczuH pushed a commit to KaczuH/django-easy-audit that referenced this issue Apr 20, 2024
Replaced standard threading with 'asgiref.local' in EasyAuditMiddleware. Also, made EasyAuditMiddleware extend Django's MiddlewareMixin to automatically handle sync and async execution modes.
Github issue: soynatan#291
@reckless-huang
Copy link

This is a good PR, why is there no response?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants