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


Python Message._query方法代码示例

本文整理汇总了Python中r2.models.Message._query方法的典型用法代码示例。如果您正苦于以下问题:Python Message._query方法的具体用法?Python Message._query怎么用?Python Message._query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在r2.models.Message的用法示例。


在下文中一共展示了Message._query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _add_message_nolock

# 需要导入模块: from r2.models import Message [as 别名]
# 或者: from r2.models.Message import _query [as 别名]
def _add_message_nolock(key, message):
    from r2.models import Account, Message
    trees = g.permacache.get(key)
    if not trees:
        # in case an empty list got written at some point, delete it to
        # force a recompute
        if trees is not None:
            g.permacache.delete(key)
        # no point computing it now.  We'll do it when they go to
        # their message page.
        return

    # if it is a new root message, easy enough
    if message.first_message is None:
        trees.insert(0, (message._id, []))
    else:
        tree_dict = dict(trees)

        # if the tree already has the first message, update the list
        if message.first_message in tree_dict:
            if message._id not in tree_dict[message.first_message]:
                tree_dict[message.first_message].append(message._id)
                tree_dict[message.first_message].sort()
        # we have to regenerate the conversation :/
        else:
            m = Message._query(Message.c.first_message == message.first_message,
                               data = True)
            new_tree = compute_message_trees(m)
            if new_tree:
                trees.append(new_tree[0])
        trees.sort(key = tree_sort_fn, reverse = True)

    # done!
    g.permacache.set(key, trees)
开发者ID:VincentVazzo,项目名称:reddit,代码行数:36,代码来源:comment_tree.py

示例2: _conversation

# 需要导入模块: from r2.models import Message [as 别名]
# 或者: from r2.models.Message import _query [as 别名]
def _conversation(trees, parent):
    from r2.models import Message
    if parent._id in trees:
        convo = trees[parent._id]
        if convo:
            m = Message._byID(convo[0], data=True)
        if not convo or m.first_message == m.parent_id:
            return [(parent._id, convo)]

    # if we get to this point, either we didn't find the conversation,
    # or the first child of the result was not the actual first child.
    # To the database!
    m = Message._query(Message.c.first_message == parent._id, data=True)
    return compute_message_trees([parent] + list(m))
开发者ID:rtnielson,项目名称:reddit,代码行数:16,代码来源:comment_tree.py

示例3: _conversation

# 需要导入模块: from r2.models import Message [as 别名]
# 或者: from r2.models.Message import _query [as 别名]
def _conversation(trees, parent):
    from r2.models import Message
    if parent._id in trees:
        convo = trees[parent._id]
        if convo:
            m = Message._byID(convo[0], data = True)
        if not convo or m.first_message == m.parent_id:
            return [(parent._id, convo)]

    # if we get to this point, either we didn't find the conversation,
    # or the first child of the result was not the actual first child.
    # To the database!
    rules = [Message.c.first_message == parent._id]
    if c.user_is_admin:
        rules.append(Message.c._spam == (True, False))
        rules.append(Message.c._deleted == (True, False))
    m = Message._query(*rules, data=True)
    return compute_message_trees([parent] + list(m))
开发者ID:Omosofe,项目名称:reddit,代码行数:20,代码来源:comment_tree.py

示例4: get_sent

# 需要导入模块: from r2.models import Message [as 别名]
# 或者: from r2.models.Message import _query [as 别名]
def get_sent(user):
    q = Message._query(Message.c.author_id == user._id,
                       Message.c._spam == (True, False),
                       sort = desc('_date'))
    return make_results(q)
开发者ID:rram,项目名称:reddit,代码行数:7,代码来源:queries.py

示例5: get_sent

# 需要导入模块: from r2.models import Message [as 别名]
# 或者: from r2.models.Message import _query [as 别名]
def get_sent(user_id):
    return Message._query(Message.c.author_id == user_id,
                          Message.c._spam == (True, False),
                          sort = desc('_date'))
开发者ID:WyriHaximus,项目名称:reddit,代码行数:6,代码来源:queries.py


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