A useful utility classmethod.

This commit is contained in:
Ralph Bean
2016-07-13 16:55:41 -04:00
parent ff831df01d
commit 0859641cb8

View File

@@ -121,6 +121,12 @@ class ModuleBuild(Base):
return BUILD_STATES[field]
raise ValueError("%s: %s, not in %r" % (key, field, BUILD_STATES))
@classmethod
def from_fedmsg(cls, session, msg):
if '.module.' not in msg['topic']:
raise ValueError("%r is not a module message." % msg['topic'])
return session.query(cls).filter_by(cls.id==msg['msg']['id'])
def json(self):
return {
'id': self.id,