当前位置: 首页>>代码示例>>Python>>正文


Python Category.get方法代码示例

本文整理汇总了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()
开发者ID:fph,项目名称:indico,代码行数:30,代码来源:tasks.py

示例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)
开发者ID:indico,项目名称:indico,代码行数:9,代码来源:creation.py

示例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)
开发者ID:ThiefMaster,项目名称:indico,代码行数:11,代码来源:fields.py


注:本文中的indico.modules.categories.Category.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。