我无法在会话中检索已动态添加到数据存储对象的属性。这是一个(简化的)示例...为了节省建议时间,我不想将属性实际硬编码到数据存储对象。
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
知道为什么会这样吗?