本文整理汇总了Python中Message.Message.put方法的典型用法代码示例。如果您正苦于以下问题:Python Message.put方法的具体用法?Python Message.put怎么用?Python Message.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message.Message
的用法示例。
在下文中一共展示了Message.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_new_conversation
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import put [as 别名]
def add_new_conversation(cls, sender, receiver, title, content):
"""Adds new conversation with receiver for sender, returns Conversation object
"""
#TODO: check if sender and receiver aren't the same person, if so, add only once
skey = ndb.Key('User', sender)
rkey = ndb.Key('User', receiver)
if sender == receiver:
rl = [skey]
rln = [sender]
else:
rl = [rkey, skey]
rln = [sender, receiver]
conv = Conversation(
owner = sender,
receivers_list = rl,
receivers_list_norm = rln,
title = title,
)
msg = Message(
sender = sender,
content = content
)
k = msg.put()
conv.insert_message(k)
ck = conv.put()
User.add_conversation_for_users(ck, sender, receiver)
return conv, msg
示例2: add_new_conversation
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import put [as 别名]
def add_new_conversation(cls, sender, receiver, title, content):
"""Adds new conversation with receiver for sender, returns Conversation object
Args:
sender: sender's username as string
receiver: receiver's username as string
title: title of the conversation
content: content of the first post
Returns:
tupple with:
newly created Conversation instance
newly created Message instance
"""
#TODO: check if sender and receiver aren't the same person, if so, add only once
skey = ndb.Key('User', sender)
rkey = ndb.Key('User', receiver)
if sender == receiver:
rl = [skey]
rln = [sender]
else:
rl = [rkey, skey]
rln = [sender, receiver]
conv = Conversation(
owner = sender,
receivers_list = rl,
receivers_list_norm = rln,
title = title,
)
msg = Message(
sender = sender,
content = content
)
k = msg.put()
conv.insert_message(k)
ck = conv.put()
User.add_conversation_for_users(ck, sender, receiver)
return conv, msg