本文整理汇总了Python中indico.modules.categories.Category.get方法的典型用法代码示例。如果您正苦于以下问题:Python Category.get方法的具体用法?Python Category.get怎么用?Python Category.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.categories.Category
的用法示例。
在下文中一共展示了Category.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: category_cleanup
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get [as 别名]
def category_cleanup():
from indico.modules.events import Event
cfg = Config.getInstance()
janitor_user = User.get_one(cfg.getJanitorUserId())
logger.debug("Checking whether any categories should be cleaned up")
for categ_id, days in cfg.getCategoryCleanup().iteritems():
try:
category = Category.get(int(categ_id), is_deleted=False)
except KeyError:
logger.warning("Category %s does not exist!", categ_id)
continue
now = now_utc()
to_delete = Event.query.with_parent(category).filter(Event.created_dt < (now - timedelta(days=days))).all()
if not to_delete:
continue
logger.info("Category %s: %s events were created more than %s days ago and will be deleted", categ_id,
len(to_delete), days)
for i, event in enumerate(to_delete, 1):
logger.info("Deleting %s", event)
event.as_legacy.delete(user=janitor_user)
if i % 100 == 0:
db.session.commit()
DBMgr.getInstance().commit()
db.session.commit()
DBMgr.getInstance().commit()
示例2: _default_category
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get [as 别名]
def _default_category(self):
try:
category_id = int(request.args['category_id'])
except (ValueError, KeyError):
return self.root_category if self.single_category else None
else:
return Category.get(category_id, is_deleted=False)
示例3: process_formdata
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get [as 别名]
def process_formdata(self, valuelist):
from indico.modules.categories import Category
if valuelist:
try:
category_id = int(json.loads(valuelist[0])['id'])
except KeyError:
self.data = None
else:
self.data = Category.get(category_id, is_deleted=False)