本文整理汇总了Python中penelope.core.models.DBSession.count方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.count方法的具体用法?Python DBSession.count怎么用?Python DBSession.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类penelope.core.models.DBSession
的用法示例。
在下文中一共展示了DBSession.count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pre_process_request
# 需要导入模块: from penelope.core.models import DBSession [as 别名]
# 或者: from penelope.core.models.DBSession import count [as 别名]
def pre_process_request(self, req, handler):
if isinstance(handler, Chrome):
# return ASAP if we are serving a static resource
return handler
req.ticket_time_entries = []
if isinstance(handler, TicketModule):
project_id = self.env.config.get('por-dashboard', 'project-id')
ticket_id = req.args.get('id', None)
if ticket_id and project_id:
timeentries = DBSession().query(TimeEntry)\
.filter_by(project_id=project_id)\
.filter_by(ticket=int(ticket_id)).order_by(TimeEntry.date.desc(), TimeEntry.modification_date.desc())
delta = datetime.timedelta()
delta_tot = sum([e.hours for e in timeentries], delta)
req.ticket_time_entries_total = timedelta_as_human_str(delta_tot)
req.ticket_time_entries = timeentries[:20]
req.ticket_time_entries_count = timeentries.count()
return handler