Comment 23 for bug 1491117

Revision history for this message
Andrew Bruce (andybrucenet) wrote :

Hello maintainers...I have about 8 minutes to spend on this particular bug and my fix I'm sure falls under "monkey patching" from above. Basically, the problem is that the session key is stored in the data schema as an "AutoField" with a default conversion to Integer in the to_python method. Which fails with session keys as they are Very Long Strings of Chars. I took a quick look at the proposed changes and my brain doesn't grok how setting the user_id in keystone auth changes things??

The solution I used...stupidly simple so I'm sure wrong:

def _get_user_session_key(request):
    # This value in the session is always serialized to a string, so we need
    # to convert it back to Python whenever we access it.
    #return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
    # ABr, 20150916: newsflash...this will never be an int. so the above call loses every time.
    if request.session[SESSION_KEY] is None:
        return None
    return str(request.session[SESSION_KEY])

Is there really any way that the session key could be anything but a string??