本文整理汇总了Python中request.Request.all方法的典型用法代码示例。如果您正苦于以下问题:Python Request.all方法的具体用法?Python Request.all怎么用?Python Request.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request.Request
的用法示例。
在下文中一共展示了Request.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: can_purge
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import all [as 别名]
def can_purge(user,contentcopy):
from cache import ContentCopy, TYPE_COMPUTER
allCopies = ContentCopy.all().filter("content =",contentcopy.content).fetch(limit = 1000) #now fetch all the copies
allCopies = filter(available_soon_cc,allCopies) #only the ones that are online
if len(allCopies) > LEAVE_COPIES_ON_DARKNET+1:
copies_on_team = 0
chk_team = team_of(contentcopy)
for copy in allCopies:
if copy.key()==contentcopy.key(): continue #not interested in the copy we want to purge
if chk_team.key()==team_of(copy).key(): copies_on_team += 1
if copies_on_team >= LEAVE_COPIES_ON_TEAM:
if not user.team_leader_flag: #wait for the team leader to purge the crap.
team_leader_copies = filter(lambda x: x.where.type==TYPE_COMPUTER, copies_on_team)
from user_sn import all_team_leaders_for
leaders = all_team_leaders_for(user.team)
leaders = map(lambda x: x.key(),leaders)
team_leader_copies = filter(lambda x: x.where.last_touched.key() in leaders)
if len(team_leader_copies) != 0:
logging.info("Team leader has a copy. Not purging.")
return MOVE_TO_SOFTCACHE
else:
return PURGE_AT_WILL
#this is conservative logic. If there's an outstanding request on the sneakernet, leave the file in place
from request import Request
reqs = Request.all().filter("file =",contentcopy.content).get()
if reqs==None:
return MOVE_TO_SOFTCACHE
return LEAVE_IN_PLACE
示例2: get
# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import all [as 别名]
def get(self):
req = Request.all().order("last_routed").get()
try_to_route(req)