def update(self, schedule):
"""Update the registered schedule by reconciliating with database
backend.
:param schedule: Schedule to synchronize with the database.
:type schedule: :class:`~news.models.AbstractSchedule` implementation
"""
if isinstance(schedule, int):
schedule = self.backend.get_schedule_by_id(schedule)
# log
self._log('Updating schedule {}'.format(
schedule if isinstance(schedule, int) else schedule.id))
# remove schedule from job queue and add it if it's now enabled
self.remove_schedule(schedule)
if schedule.enabled:
self.add_schedule(schedule)
# ==================
# Celery integration
# ==================
评论列表
文章目录