我有一個名爲Conversation
一些領域,包括date_created
和date_updated
爲DateTimePropterty
與auto_now_add
和auto_now
模型。GAE蟒蛇NDB put_async問題
如果我更新使用put()
方法模型,date_updated
場得到更新。 但是,當我使用put_async
方法時,date_updated
字段中的值未更新。
而且我也有使用Python的unittest.Testcase
的測試用例,它工作正常。
注意:它適用於我使用put_async().get_result()
。
樣品模型類:
class Conversation(ndb.Model):
participants = ndb.StringProperty(repeated=True)
conversation_name = ndb.StringProperty()
date_created = ndb.DateTimeProperty(required=True, auto_now_add=True)
date_updated = ndb.DateTimeProperty(required=True, auto_now=True)
@staticmethod
def update_conversation_date_by_id(conversation_id):
conversation = Conversation.get_by_id(conversation_id) if conversation_id else None
if conversation is None:
raise CannotFindEntity("Given conversation_id is not found")
else:
conversation.put_async().get
return conversation
可能重複http://stackoverflow.com上/問題/ 11621313/IS-NDB-異步保證對執行-後的應用程序請求-具有成品) –