0
我无法检索会话中已动态添加到数据存储对象的属性。这是一个(简化的)示例...为了节省建议时间,我不想实际将属性硬编码到数据存储对象。为什么我无法将属性添加到数据存储对象(动态)并将其存储在会话中?
Class User(ndb.Model):
email = ndb.String...
// I use a handler to get the user object from the datastore
// and store the object in session
user = function_to_get_user_by_key(key)
// Add an temporary attribute
user.temp_var = 'test'
// Store in session
self.session['user'] = user
// Get the user in the same script to test the attribute
user = self.session.get('user')
print user.temp_var // Works - I see the result
// Redirect to a new script (By the way, assume these scripts are in separate methods within a handler class)
user = self.session.get('user')
print user.temp_var // Gives an attribute error - basically saying the class does not have this attribute
任何想法为什么发生这种情况?