本文整理汇总了Python中indico.modules.events.Event.title_matches方法的典型用法代码示例。如果您正苦于以下问题:Python Event.title_matches方法的具体用法?Python Event.title_matches怎么用?Python Event.title_matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.events.Event
的用法示例。
在下文中一共展示了Event.title_matches方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _iterate_objs
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import title_matches [as 别名]
def _iterate_objs(query_string):
query = (Event.query
.filter(Event.title_matches(to_unicode(query_string)),
~Event.is_deleted)
.options(undefer('effective_protection_mode')))
sort_dir = db.desc if self._descending else db.asc
if self._orderBy == 'start':
query = query.order_by(sort_dir(Event.start_dt))
elif self._orderBy == 'end':
query = query.order_by(sort_dir(Event.end_dt))
elif self._orderBy == 'id':
query = query.order_by(sort_dir(Event.id))
elif self._orderBy == 'title':
query = query.order_by(sort_dir(db.func.lower(Event.title)))
counter = 0
# Query the DB in chunks of 1000 records per query until the limit is satisfied
for event in query.yield_per(1000):
if event.can_access(self._user):
counter += 1
# Start yielding only when the counter reaches the given offset
if (self._offset is None) or (counter > self._offset):
yield event
# Stop querying the DB when the limit is satisfied
if (self._limit is not None) and (counter == self._offset + self._limit):
break
示例2: _iterate_objs
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import title_matches [as 别名]
def _iterate_objs(query_string):
query = Event.find(Event.title_matches(to_unicode(query_string)), ~Event.is_deleted)
if self._orderBy == 'start':
query = query.order_by(Event.start_dt)
elif self._orderBy == 'id':
query = query.order_by(Event.id)
counter = 0
# Query the DB in chunks of 1000 records per query until the limit is satisfied
for event in query.yield_per(1000):
if event.can_access(self._aw.getUser().user if self._aw.getUser() else None):
counter += 1
# Start yielding only when the counter reaches the given offset
if (self._offset is None) or (counter > self._offset):
yield event
# Stop querying the DB when the limit is satisfied
if (self._limit is not None) and (counter == self._offset + self._limit):
break