"""Courses. """ import grok from zope.interface import implementedBy from zope.component.interfaces import IFactory from waeup.sirp.interfaces import ICourse class Course(grok.Model): """A university course. """ grok.implements(ICourse) def __init__(self, title=u'Unnamed Course', code=u'NA', level=None, credits=0, passmark=40, semester=1, **kw): super(Course, self).__init__(**kw) self.title = title self.code = code self.level = level self.credits = credits self.passmark = passmark self.semester = semester class CourseFactory(grok.GlobalUtility): """A factory for courses. """ grok.implements(IFactory) grok.name(u'waeup.Course') title = u"Create a new course.", description = u"This factory instantiates new course instances." def __call__(self, *args, **kw): return Course(*args, **kw) def getInterfaces(self): return implementedBy(Course)