def from_schedule(cls, session, schedule):
spec = {'minute': schedule._orig_minute,
'hour': schedule._orig_hour,
'day_of_week': schedule._orig_day_of_week,
'day_of_month': schedule._orig_day_of_month,
'month_of_year': schedule._orig_month_of_year}
obj = cls.filter_by(session, **spec).first()
if obj is None:
return cls(**spec)
else:
return obj
评论列表
文章目录