"""Courses. """ import grok from zope.interface import implementedBy from zope.component.interfaces import IFactory from waeup.sirp.university.interfaces import ICourse, ICourseAdd class Course(grok.Model): """A university course. """ grok.implements(ICourse, ICourseAdd) def __init__(self, title=u'Unnamed Course', code=u'NA', credits=0, passmark=40, semester=1, **kw): super(Course, self).__init__(**kw) self.title = title self.code = code 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)