Use module.transition to change states.

This commit is contained in:
Ralph Bean
2016-07-15 14:01:41 -04:00
parent 2344e03f23
commit 44e35c3a09
3 changed files with 15 additions and 5 deletions

View File

@@ -38,6 +38,9 @@ from sqlalchemy.orm import (
)
from sqlalchemy.ext.declarative import declarative_base
import logging
log = logging.getLogger(__name__)
# Just like koji.BUILD_STATES, except our own codes for modules.
BUILD_STATES = {
@@ -143,6 +146,12 @@ class ModuleBuild(Base):
raise ValueError("%r is not a module message." % msg['topic'])
return session.query(cls).filter(cls.id==msg['msg']['id']).one()
def transition(self, state):
""" Record that a build has transitioned state. """
old_state = self.state
self.state = state
log.debug("%r, state %r->%r" % (old_state, self.state))
def json(self):
return {
'id': self.id,