Reputation: 1467
I am trying to store a UserID in a session variable in Google App Engine (Python).
The session variable functionality works fine. In fact, I can even store the key in a session. This works:
self.session['Xuser'] = user.key.id()
This does not work:
self.session['Xuser'] = users.get_current_user()
I even tried tricking the system by putting the UserID into another variable first. This also does not work:
tempcode = users.get_current_user()
self.session['Xuser'] = tempcode
The problem is solely with the 2nd line when I try to put the UserID into the session variable. Can anyone tell me why and what I need to do to be able to store the UserID in a session variable in such a way that I can compare it
I need to do this because I have a UserSupplement kind and I don't want a user to be able to put more than one entry into this kind for the same UserID.
Thanks.
Upvotes: 1
Views: 146
Reputation: 16890
Try
self.session['Xuser'] = users.get_current_user().user_id()
Upvotes: 1
Reputation: 80340
All objects that you want to store in session must be serializable. User
obviously isn't.
Upvotes: 1