本文整理汇总了Python中api.models.User.find方法的典型用法代码示例。如果您正苦于以下问题:Python User.find方法的具体用法?Python User.find怎么用?Python User.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.models.User
的用法示例。
在下文中一共展示了User.find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_snapshots
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import find [as 别名]
def make_snapshots(year, month, day):
users = set(u._id for u in User.find(fields=[]))
for hour in xrange(24):
#load tri_edges
path = os.path.join("../tri_edge", year, month, day, str(hour))
tri_edges = set(
tuple(int(id) for id in line.split())
for line in open(path))
#process this hour
time = datetime(int(year), int(month), int(day), hour)
while time.hour==int(hour):
graph = make_graph(time, users, tri_edges)
graph.save()
time += TIME_DELAY
print "saved %s/%s/%s"%(year,month,day)
示例2: users
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import find [as 别名]
def users(cid):
"returns all the users in a crowd"
crowd = get_or_404(Crowd,cid)
uids = [u['id'] for u in crowd.users]
users = User.find(User._id.is_in(uids))
return [u.to_d() for u in users]