Skip to content

Conversation

tomasgarzon
Copy link

Allow getting the user from the cache, not only from django-db. Using SessionStore abstraction.

session = Session.objects.get(session_key=session_id)
except Session.DoesNotExist:
session = None
engine = import_module(settings.SESSION_ENGINE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't particularly mind this flow, but is there a less brutal way of doing this for users that do not require as much flexibility in the call flow? Maybe a new settings flag?
Also, is there harm in resolving the engine in the module scope, as opposed to the function scope? (Perhaps there is, like a django init thing, but wanted to ask just in case there was no danger.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to the use of import_module? It's the recommended way in the Django docs. If the user is retrieved from request.user this would not be required at all actually (see my comment in #165).

I agree that the session store should be retrieved once instead of each request. Maybe move it to the top of the module where audit_logger is defined?

Copy link
Collaborator

@jheld jheld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some thoughts and look forward to your insight.

@CleitonDeLima
Copy link

I decided to test django-easy-audit and I liked this project.
I had this problem, my sessions are saved in redis and not in django-db. Do you have any predictions for this fix coming in?

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

Successfully merging this pull request may close these issues.

4 participants