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

Fix Connector from session constructor #460

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions omeroweb/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ def from_session(request):
v = request.session.get("connector", None)
if v is None:
return None
if isinstance(v, Connector):
return v
Copy link
Member

Choose a reason for hiding this comment

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

As shown by the testing, one of the issue of trying to re-use an existing Connector object from a previous (pre-upgrade) session is that it leaves other objects like request.session["connector"] in a state incompatible with the assumptions of the OMERO.web code.

#435 discusses other scenarios which might lead to similar incompatible states e.g. switching between different session serializers. From a discussion with @chris-allan, we probably need to be more defensive in OMERO.web, catch these scenarios and ensure a new session get created. From the user perspective, this will either happen automatically if the public user is configured or redirect to the login page.

Specifically in that case, could we catch the scenarios where v is not a dictionary that can be used to instantiate a Connector and return None with a logging statement (warn?)

Copy link
Member

Choose a reason for hiding this comment

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

Another suggestion: reset the session connector as JSON here:

if isinstance(v, Connector):
    v.to_session(request)
    return v

return Connector(**v)

def to_session(self, request):
Expand Down