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

Last change on this file since 5126 was 5005, checked in by uli, 15 years ago

Fix references to academics stuff interfaces. This is the first step to make academics stuff pluggable.

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