本文整理汇总了Python中models.Log.all方法的典型用法代码示例。如果您正苦于以下问题:Python Log.all方法的具体用法?Python Log.all怎么用?Python Log.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Log
的用法示例。
在下文中一共展示了Log.all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RenderTranscript
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import all [as 别名]
def RenderTranscript(self):
channel = self.request.get('channel', '')
values = {
'channel': channel,
}
# Query for the correct set of logs.
query = Log.all().filter('channel =', channel)
if 'start_time' in self.request.GET:
# Followed a 'next page' link
query.order('timestamp')
t = time.strptime(self.request.GET['start_time'], '%Y%m%d%H%M%S')
query.filter('timestamp >=', datetime.datetime(*t[0:6]))
# Fetch N+1 to check for a next page
logs = query.fetch(self._TRANSCRIPT_LINES + 1)
values['first_time'] = logs[0].timestamp.strftime('%Y%m%d%H%M%S')
if len(logs) > self._TRANSCRIPT_LINES:
logs = logs[0:self._TRANSCRIPT_LINES]
values['last_time'] = logs[-1].timestamp.strftime('%Y%m%d%H%M%S')
else:
query.order('-timestamp')
reversed = True
if 'end_time' in self.request.GET:
# Followed a 'prev page' link
t = time.strptime(self.request.GET['end_time'], '%Y%m%d%H%M%S')
t = list(t[0:6])
t[5] += 1 # round up so we ignore fractional seconds
query.filter('timestamp <=', datetime.datetime(*t))
# Fetch N+1 to check for a prev page
logs = query.fetch(self._TRANSCRIPT_LINES + 1)
values['last_time'] = logs[0].timestamp.strftime('%Y%m%d%H%M%S')
else:
# No 'prev/next' links followed, so no filter
# Fetch N+1 to check for a prev page
logs = query.fetch(self._TRANSCRIPT_LINES + 1)
if len(logs) > self._TRANSCRIPT_LINES:
logs = logs[0:self._TRANSCRIPT_LINES]
values['first_time'] = logs[-1].timestamp.strftime('%Y%m%d%H%M%S')
logs.reverse()
values['logs'] = logs
# Adjust timezone if requested.
if 'tz' in self.request.GET:
tz = FixedOffsetZone(int(self.request.get('tz')))
for log in logs:
t = log.timestamp + tz.utcoffset(log.timestamp)
log.timestamp = t.replace(tzinfo=tz)
self.Render('transcript.html', values)