Last change
on this file since 7167 was
7137,
checked in by Henrik Bettermann, 13 years ago
|
Set value Id for property svn:keywords in all Python files.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
1.1 KB
|
Rev | Line | |
---|
[4789] | 1 | """Courses. |
---|
| 2 | """ |
---|
| 3 | import grok |
---|
| 4 | from zope.interface import implementedBy |
---|
| 5 | from zope.component.interfaces import IFactory |
---|
[5953] | 6 | from waeup.sirp.university.interfaces import ICourse, ICourseAdd |
---|
[4789] | 7 | |
---|
| 8 | class Course(grok.Model): |
---|
| 9 | """A university course. |
---|
| 10 | """ |
---|
[5953] | 11 | grok.implements(ICourse, ICourseAdd) |
---|
[4789] | 12 | |
---|
| 13 | def __init__(self, |
---|
| 14 | title=u'Unnamed Course', |
---|
| 15 | code=u'NA', |
---|
| 16 | credits=0, |
---|
| 17 | passmark=40, |
---|
| 18 | semester=1, **kw): |
---|
| 19 | super(Course, self).__init__(**kw) |
---|
| 20 | self.title = title |
---|
| 21 | self.code = code |
---|
| 22 | self.credits = credits |
---|
| 23 | self.passmark = passmark |
---|
| 24 | self.semester = semester |
---|
[6566] | 25 | |
---|
[6008] | 26 | def longtitle(self): |
---|
[6566] | 27 | return "%s (%s)" % (self.title,self.code) |
---|
| 28 | |
---|
[4789] | 29 | class CourseFactory(grok.GlobalUtility): |
---|
| 30 | """A factory for courses. |
---|
| 31 | """ |
---|
| 32 | grok.implements(IFactory) |
---|
| 33 | grok.name(u'waeup.Course') |
---|
| 34 | title = u"Create a new course.", |
---|
| 35 | description = u"This factory instantiates new course instances." |
---|
| 36 | |
---|
| 37 | def __call__(self, *args, **kw): |
---|
| 38 | return Course(*args, **kw) |
---|
| 39 | |
---|
| 40 | def getInterfaces(self): |
---|
| 41 | return implementedBy(Course) |
---|
Note: See
TracBrowser for help on using the repository browser.