-
Notifications
You must be signed in to change notification settings - Fork 7
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
DetachedInstanceError on login #79
Comments
The workaround above still failed in some cases, where object_session returned None. Another seemingly more reliable version of avoiding that exception is to change the implementation of if request.unauthenticated_userid:
try:
user = pyramid_basemodel.Session.query(User).filter(
User.id == request.unauthenticated_userid
).options(joinedload('groups')).one()
pyramid_basemodel.Session.expunge(user)
return user
except NoResultFound: # pragma: no cover
pass The call to expunge to make sure the user object can be used even if detached, and the joinedload of groups since we access that too. |
Okay, it looks like it fails on the first request to load? |
I am importing Session from pyramid_basemodel. I noticed one machine was on pyramid 1.6.1 and the other 1.7. But updating that made no difference. |
I did notice that the traceback contained |
Okay then... this should not have happened... groupfinder doesn't have much in it to justify such behaviour. and neither does request.user.... You're using transactions package, right? |
This might be due to my setup, but I am not yet sure exactly why I see this so I am filing an issue.
The confusing part is that I see this on one machine but not the other, and I have not yet pinpointed the difference. Could be some setup/environment that is different - or simply some timing issue.
Anyway this happens consistently when I try to login:
so apparently the
request.user
instance is no longer bound to a session. Was it closed too early ?Adding these lines to groupfinder() in auth.py:
right before the user variable is used reattaches it and all seem to work fine. Possibly there could also be a check to only use refresh if really needed.
However, I am not sure why I am even seeing this problem. Any idea ?
The text was updated successfully, but these errors were encountered: