source: main/waeup.sirp/trunk/src/waeup/sirp/university/course.txt @ 6447

Last change on this file since 6447 was 5944, checked in by Henrik Bettermann, 14 years ago

Remove level attribute from course class.

File size: 3.6 KB
Line 
1:mod:`waeup.sirp.university.course` -- Courses
2**********************************************
3
4.. module:: waeup.sirp.university.course
5
6Components that represent courses.
7
8.. :doctest:
9.. :layer: waeup.sirp.testing.WAeUPSIRPUnitTestLayer
10
11Content Classes (models and containers)
12=======================================
13
14:class:`Course`
15---------------
16
17.. class:: Course([code=u'NA'[, title=u'Unnamed Course'[, credits=0[, passmark=40[, semester=1]]]]]])
18
19   Create a course instance with the given parameters.
20
21   .. attribute:: grok.implements(ICourse)
22
23   All parameters are optional:
24
25     >>> from waeup.sirp.university.course import Course
26     >>> mycourse = Course()
27     >>> mycourse
28     <waeup.sirp.university.course.Course object at 0x...>
29
30   Course instances have the attributes required by the
31   :class:`waeup.sirp.interfaces.ICourse` interface:
32
33     >>> from waeup.sirp.university.interfaces import ICourse
34     >>> ICourse.providedBy(mycourse)
35     True
36
37     >>> from zope.interface.verify import verifyObject
38     >>> verifyObject(ICourse, mycourse)
39     True
40
41   .. attribute:: title
42
43      Each course has a title:
44
45        >>> mycourse.title
46        u'Unnamed Course'
47
48   .. attribute:: code
49
50      Each course holds a code, which might be a shortcut or
51      abbreviation of the real course name. By default the code is
52      ``NA`` (=not assigned).
53
54      This value has to be unique if used in a :class:`Department`
55      instance as it serves as a key:
56
57        >>> mycourse.code
58        u'NA'
59
60   .. attribute:: passmark
61
62      Each course holdes a passmark, which is ``40`` by default:
63
64        >>> mycourse.passmark
65        40
66
67   .. attribute:: semester
68
69      Each course holds a semester attribute which is ``1`` by
70      default:
71
72        >>> mycourse.semester
73        1
74
75   .. attribute:: credits
76
77      Each course holds the number of credits that can be
78      earned. Default is ``0``.
79
80        >>> mycourse.credits
81        0
82
83
84
85Utilities
86=========
87
88:class:`CourseFactory`
89---------------------------
90
91.. class:: CourseFactory()
92
93   .. attribute:: grok.name(u'waeup.Course')
94
95   .. attribute:: grok.implements(IFactory)
96
97   A named utility to deliver new instances of :class:`Course`
98   without the need to import the implementation before:
99
100     >>> from zope.component import createObject
101     >>> mycourse = createObject(u'waeup.Course')
102     >>> mycourse
103     <waeup.sirp.university.course.Course object at 0x...>
104
105   The factory complies with the specifications from the
106   :class:`IFactory` insterface:
107
108     >>> from zope.interface.verify import verifyClass
109     >>> from zope.component.interfaces import IFactory
110     >>> from waeup.sirp.university.course import CourseFactory
111     >>> verifyClass(IFactory, CourseFactory)
112     True
113
114   This means also, that we can get the interfaces of the created
115   object from the factory:
116
117     >>> course_factory = CourseFactory()
118     >>> course_factory.getInterfaces()
119     <implementedBy waeup.sirp.university.course.Course>
120
121Examples
122========
123
124Creating courses
125----------------
126
127The simplest way to create a :class:`Course` instance is to import the
128class and calling the constructor:
129
130    >>> from waeup.sirp.university.course import Course
131    >>> mycourse = Course()
132    >>> mycourse
133    <waeup.sirp.university.course.Course object at 0x...>
134
135Another way to create courses is by asking for a factory called
136``waeup.Course``. This way we can create a factory without importing a
137class:
138
139    >>> from zope.component import createObject
140    >>> mycourse = createObject(u'waeup.Course')
141    >>> mycourse
142    <waeup.sirp.university.course.Course object at 0x...>
143
Note: See TracBrowser for help on using the repository browser.