本文整理汇总了Python中indico.modules.events.Event.find方法的典型用法代码示例。如果您正苦于以下问题:Python Event.find方法的具体用法?Python Event.find怎么用?Python Event.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.events.Event
的用法示例。
在下文中一共展示了Event.find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: category_extra
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import find [as 别名]
def category_extra(self, ids):
if self._toDT is None:
has_future_events = False
else:
query = Event.find(Event.category_id.in_(ids), ~Event.is_deleted, Event.start_dt > self._toDT)
has_future_events = query.has_rows()
return {"eventCategories": self._build_category_path_data(ids), "moreFutureEvents": has_future_events}
示例2: category_extra
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import find [as 别名]
def category_extra(self, ids):
if self._toDT is None:
has_future_events = False
else:
query = Event.find(Event.category_id.in_(ids), ~Event.is_deleted, Event.start_dt > self._toDT)
has_future_events = db.session.query(query.exists()).one()[0]
return {
'eventCategories': self._build_category_path_data(ids),
'moreFutureEvents': has_future_events
}
示例3: migrate_event_managers
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import find [as 别名]
def migrate_event_managers(self):
self.print_step("migrating event managers/creators")
creator_updates = []
for event in committing_iterator(self._iter_events(), 5000):
self.print_success("", event_id=event.id)
ac = event._Conference__ac
entries = {}
# add creator as a manager
try:
creator = event._Conference__creator
except AttributeError:
# events created after the removal of the `self.__creator` assignment
# should happen only on dev machines
self.print_error(cformat("%{red!}Event has no creator attribute"), event_id=event.id)
else:
user = self.process_principal(event, entries, creator, "Creator", "green!", full_access=True)
if user:
creator_updates.append({"event_id": int(event.id), "creator_id": user.id})
# add managers
for manager in ac.managers:
self.process_principal(event, entries, manager, "Manager", "blue!", full_access=True)
# add email-based managers
emails = getattr(ac, "managersEmail", [])
self.process_emails(event, entries, emails, "Manager", "green", full_access=True)
# add registrars
for registrar in getattr(event, "_Conference__registrars", []):
self.process_principal(event, entries, registrar, "Registrar", "cyan", roles={"registration"})
# add submitters
for submitter in getattr(ac, "submitters", []):
self.process_principal(event, entries, submitter, "Submitter", "magenta!", roles={"submit"})
# email-based (pending) submitters
pqm = getattr(event, "_pendingQueuesMgr", None)
if pqm is not None:
emails = set(getattr(pqm, "_pendingConfSubmitters", []))
self.process_emails(event, entries, emails, "Submitter", "magenta", roles={"submit"})
db.session.add_all(entries.itervalues())
# assign creators
if creator_updates:
self.print_step("saving event creators")
stmt = (
Event.__table__.update()
.where(Event.id == db.bindparam("event_id"))
.values(creator_id=db.bindparam("creator_id"))
)
db.session.execute(stmt, creator_updates)
updated = Event.find(Event.creator_id == None).update({Event.creator_id: self.janitor.id}) # noqa
db.session.commit()
self.print_success("Set the janitor user {} for {} events".format(self.janitor, updated), always=True)
示例4: _iterate_objs
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import find [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
示例5: _iter_events
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import find [as 别名]
def _iter_events(self):
event_it = self.zodb_root['conferences'].itervalues()
events_query = Event.find(is_deleted=False).order_by(Event.id)
event_total = len(self.zodb_root['conferences'])
if self.parallel:
n, i = self.parallel
event_it = (e for e in event_it if int(e.id) % n == i)
event_total = int(ceil(event_total / n))
events_query = events_query.filter(Event.id % n == i)
all_events = {ev.id: ev for ev in events_query}
if self.quiet:
event_it = verbose_iterator(event_it, event_total, attrgetter('id'), attrgetter('title'))
for conf in self.flushing_iterator(event_it):
event = all_events.get(int(conf.id))
if event is None:
self.print_error(cformat('%{red!}Event not found in DB'), event_id=conf.id)
continue
yield conf, event
示例6: preload_events
# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import find [as 别名]
def preload_events(ids, lightweight=True, persons=False):
"""Preload events so they are in SA's identity cache
This is useful for legacy pages where we have to show large
numbers of events without being able to query them from the
db cleanly.
:param ids: An iterable of IDs or Conference objects
:param lightweight: Only load dates and title
:param persons: Also load the person links
"""
cache = g.setdefault('_event_cache', {})
ids = {int(getattr(id_, 'id', id_)) for id_ in ids} - cache.viewkeys()
query = Event.find(Event.id.in_(ids))
if lightweight:
query = query.options(load_only('id', 'title', 'start_dt', 'end_dt', 'timezone'))
if persons:
query = query.options(joinedload('person_links'))
cache.update((e.id, e) for e in query)