数据存储区不会保存对实体的新更改

时间:2012-05-27 11:47:32

标签: python google-app-engine transactions datastore

我正在尝试解决一个错误。以下函数将Key对象添加到名为tabs的用户属性中。出于某种原因,在用户实体上调用put()之后,不会保存新添加的密钥。无法弄清楚原因。也许有一些延迟阻止变化立即出现?在那种情况下,memcache是​​解决方案吗?

class User(GeoModel):
    tabs = db.ListProperty(db.Key)

@db.transactional
def add_tab_transaction(self, user_key, tab_key):
    user = models.User.get(user_key)
    user.tabs.append(tab_key)
    user.put()
    logging.debug('tabs this user has:')
    logging.debug(user.tabs) # prints the list with the new value
    user = models.User.get(user_key)
    logging.debug('rechecking the same thing:')
    logging.debug(user.tabs) # prints the list without the new value

1 个答案:

答案 0 :(得分:0)

Isolation and Consistency中解释了此行为。

“在事务中,所有读取都反映了事务开始时数据存储的当前一致状态。这不包括事务中先前的放入和删除。”