当前位置: 首页>>代码示例>>Python>>正文


Python Message.put方法代码示例

本文整理汇总了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
开发者ID:nitishparkar,项目名称:udacityplus,代码行数:36,代码来源:User.py

示例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
开发者ID:Ramesh7128,项目名称:udacityplus,代码行数:47,代码来源:User.py


注:本文中的Message.Message.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。