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

Question about a potentially confusing comment #68

Open
jrobbins-LiveData opened this issue Oct 3, 2023 · 2 comments
Open

Question about a potentially confusing comment #68

jrobbins-LiveData opened this issue Oct 3, 2023 · 2 comments

Comments

@jrobbins-LiveData
Copy link

Line 93 says no matter whether it was initially empty, but lines 88 through 91 seem to have already dealt with the "initially empty" case without removing the cookie or clearing the storage. This made me unsure as to what the comment on line 93 means.

if handler.is_empty:
# if session was initially empty then do nothing
if handler.initially_empty:
await send(message)
return
# session data loaded but empty, no matter whether it was initially empty or cleared
# we have to remove the cookie and clear the storage
if not self.cookie_path or self.cookie_path and scope["path"].startswith(self.cookie_path):

@alex-oleshkevich
Copy link
Owner

initially_empty is True when session data is not loaded from the storage. In this case, we just do nothing.

In the next lines, we work with session data loaded from the storage or modified via request.session. This data can be empty {} which means that we can destroy session and remove the cookie.

@jrobbins-LiveData
Copy link
Author

initially_empty seems to be set True at then end of the handler's load method, in the case where the storage was empty. It makes sense to me that in that case we do nothing.

In the next lines, the load method must have initially seen data, setting initially_empty to False. What do the words in the comment on line 93 (no matter whether it was initially empty) mean, since the data was not initially empty here? It seems that the session data could only have been cleared or otherwise emptied by the user.

In other words, it seems that by line 93, the session data was loaded, was not empty, and then became empty. The use of the phrase "initially empty" here seems confusing, and seems to refer to the case already handled at lines 88-91.

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