models.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:flask-celery3-boilerplate 作者: sdg32 项目源码 文件源码
def from_schedule(cls, schedule):
        data = dict([
            (x, getattr(schedule, '_orig_{0}'.format(x)))
            for x in (
                'minute', 'hour', 'day_of_week', 'day_of_month', 'month_of_year'
            )
        ])
        instance = cls.query.filter(*[
            getattr(cls, k) == v for k, v in data.items()
        ]).first()
        if not instance:
            instance = cls(**data)
            db.session.add(instance)
            db.session.commit()
        return instance
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号