本文整理汇总了Python中indico.modules.categories.Category.get_tree_cte方法的典型用法代码示例。如果您正苦于以下问题:Python Category.get_tree_cte方法的具体用法?Python Category.get_tree_cte怎么用?Python Category.get_tree_cte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.categories.Category
的用法示例。
在下文中一共展示了Category.get_tree_cte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _mappers_configured
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_tree_cte [as 别名]
def _mappers_configured():
event_alias = db.aliased(Event)
# Event.category_chain -- the category ids of the event, starting
# with the root category down to the event's immediate parent.
cte = Category.get_tree_cte()
query = select([cte.c.path]).where(cte.c.id == Event.category_id).correlate_except(cte)
Event.category_chain = column_property(query, deferred=True)
# Event.effective_protection_mode -- the effective protection mode
# (public/protected) of the event, even if it's inheriting it from its
# parent category
query = (select([db.case({ProtectionMode.inheriting.value: Category.effective_protection_mode},
else_=Event.protection_mode, value=Event.protection_mode)])
.where(Category.id == Event.category_id))
Event.effective_protection_mode = column_property(query, deferred=True)
# Event.series_pos -- the position of the event in its series
subquery = (select([event_alias.id,
db.func.row_number().over(order_by=(event_alias.start_dt, event_alias.id)).label('pos')])
.where((event_alias.series_id == Event.series_id) & ~event_alias.is_deleted)
.correlate(Event)
.alias())
query = select([subquery.c.pos]).where(subquery.c.id == Event.id).correlate_except(subquery)
Event.series_pos = column_property(query, group='series', deferred=True)
# Event.series_count -- the number of events in the event's series
query = (db.select([db.func.count(event_alias.id)])
.where((event_alias.series_id == Event.series_id) & ~event_alias.is_deleted)
.correlate_except(event_alias))
Event.series_count = column_property(query, group='series', deferred=True)
示例2: category_chain_overlaps
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_tree_cte [as 别名]
def category_chain_overlaps(cls, category_ids):
"""
Create a filter that checks whether the event has any of the
provided category ids in its parent chain.
:param category_ids: A list of category ids or a single
category id
"""
from indico.modules.categories import Category
if not isinstance(category_ids, (list, tuple, set)):
category_ids = [category_ids]
cte = Category.get_tree_cte()
return (cte.c.id == Event.category_id) & cte.c.path.overlap(category_ids)