本文整理汇总了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)
示例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))
示例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))
示例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)
示例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'))