本文整理汇总了Python中models.Event.find方法的典型用法代码示例。如果您正苦于以下问题:Python Event.find方法的具体用法?Python Event.find怎么用?Python Event.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import find [as 别名]
def get(self):
required_parameters = ["token", "offset"]
for param in required_parameters:
param_value = self.request.get(param)
if not param_value:
self.response.set_status(400)
self.response.out.write("Missing parameter: %s" % param)
return
profile = ProfileManager.findByToken(self.request.get("token"))
if not profile:
self.response.set_status(400)
self.response.out.write("Invalid token")
return
if self.request.get("limit"):
limit = int(self.request.get("limit"))
else:
limit = 10
events = Event.find(profile, limit)
offset = self.request.get("offset")
if len(offset) == 5:
sign = offset[0:1]
hours = int(offset[1:3])
minutes = int(offset[3:5])
offset_seconds = hours * 3600 + minutes * 60
if sign == "-":
offset_seconds *= -1
else:
offset_seconds = 0
format = "%-16s %-30s %-s\n"
self.response.out.write(format % ("Date", "Source", "Message"))
self.response.out.write("------------------------------------------------------------------------\n")
for event in events:
event_date = event.received + timedelta(seconds=offset_seconds)
event_date = event_date.strftime("%b %d %I:%M %p")
message_for_display = event.message.replace("\n", " ")
self.response.out.write(format % (event_date, event.source,
message_for_display))
示例2: map_heatmap
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import find [as 别名]
def map_heatmap():
events = Event.find()
return render_template('map_heatmap.html', events=events)
示例3: event_list
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import find [as 别名]
def event_list():
object_list = Event.find()
return render_template('event_list.html', object_list=object_list)