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

Last change on this file since 5308 was 5140, checked in by uli, 15 years ago

Update all unit tests that use the ZCA to run inside the new unit test layer.

File size: 3.8 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'[, level=None[, 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   .. attribute:: level
84
85      Courses can have a level. This attribute is not required and the
86      default value is ``None``:
87
88        >>> mycourse.level is None
89        True
90
91
92Utilities
93=========
94
95:class:`CourseFactory`
96---------------------------
97
98.. class:: CourseFactory()
99
100   .. attribute:: grok.name(u'waeup.Course')
101
102   .. attribute:: grok.implements(IFactory)
103
104   A named utility to deliver new instances of :class:`Course`
105   without the need to import the implementation before:
106
107     >>> from zope.component import createObject
108     >>> mycourse = createObject(u'waeup.Course')
109     >>> mycourse
110     <waeup.sirp.university.course.Course object at 0x...>
111
112   The factory complies with the specifications from the
113   :class:`IFactory` insterface:
114
115     >>> from zope.interface.verify import verifyClass
116     >>> from zope.component.interfaces import IFactory
117     >>> from waeup.sirp.university.course import CourseFactory
118     >>> verifyClass(IFactory, CourseFactory)
119     True
120
121   This means also, that we can get the interfaces of the created
122   object from the factory:
123
124     >>> course_factory = CourseFactory()
125     >>> course_factory.getInterfaces()
126     <implementedBy waeup.sirp.university.course.Course>
127
128Examples
129========
130
131Creating courses
132----------------
133
134The simplest way to create a :class:`Course` instance is to import the
135class and calling the constructor:
136
137    >>> from waeup.sirp.university.course import Course
138    >>> mycourse = Course()
139    >>> mycourse
140    <waeup.sirp.university.course.Course object at 0x...>
141
142Another way to create courses is by asking for a factory called
143``waeup.Course``. This way we can create a factory without importing a
144class:
145
146    >>> from zope.component import createObject
147    >>> mycourse = createObject(u'waeup.Course')
148    >>> mycourse
149    <waeup.sirp.university.course.Course object at 0x...>
150
Note: See TracBrowser for help on using the repository browser.