source: main/waeup.sirp/trunk/src/waeup/sirp/university/faculty.txt @ 5081

Last change on this file since 5081 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: 5.3 KB
Line 
1:mod:`waeup.sirp.university.faculty` -- Faculties
2*************************************************
3
4.. module:: waeup.sirp.university.faculty
5
6Components that represent university faculties.
7
8:Test-Layer: unit
9
10Before we can create faculties, we have to grok the :mod:`waeup`
11package. This happens automatically in real-world use:
12
13    >>> import grok
14    >>> grok.testing.grok('waeup')
15
16Content Classes (models and containers)
17=======================================
18
19
20:class:`Faculty`
21----------------
22
23.. class:: Faculty(title=u'Unnamed Faculty'[, title_prefix=u'faculty' [, code=u"NA"]])
24
25   Create a representation of a university faculty:
26
27     >>> from waeup.sirp.university.faculty import Faculty
28     >>> myfac = Faculty()
29     >>> myfac
30     <waeup.sirp.university.faculty.Faculty object at 0x...>
31
32   Another way to create :class:`Faculty` instances is by asking
33   for a factory called ``waeup.Faculty``. This way we can create a
34   faculty without importing a class:
35
36     >>> from zope.component import createObject
37     >>> myfac = createObject(u'waeup.Faculty')
38     >>> myfac
39     <waeup.sirp.university.faculty.Faculty object at 0x...>
40
41   :class:`Faculty` instances have the attributes required by the
42   `IFaculty` interface:
43
44     >>> from waeup.sirp.university.interfaces import IFaculty
45     >>> IFaculty.providedBy(myfac)
46     True
47
48     >>> from zope.interface.verify import verifyObject
49     >>> verifyObject(IFaculty, myfac)
50     True
51
52   .. method:: addDepartment(department)
53
54      Add a department into this faculty. Faculties are containers for
55      departments. Added objects are checked and only `IDepartment`
56      objects accepted:
57
58        >>> myfac.addDepartment(object())
59        Traceback (most recent call last):
60        ...
61        TypeError: Faculties contain only IDepartment instances
62
63        >>> list(myfac.values())
64        []
65
66      Regular departments are accepted:
67
68        >>> from waeup.sirp.university.department import Department
69        >>> myfac.addDepartment(Department(title='Physics',
70        ...                                code='DP'))
71
72        >>> list(myfac.items())
73        [(u'DP', <waeup.sirp.university.department.Department object at 0x...>)]
74
75   .. method:: clear()
76
77      Remove all departments from this faculty:
78
79        >>> myfac.clear()
80        >>> list(myfac.items())
81        []
82
83   .. attribute:: title
84
85      (string) The title of a faculty.
86
87      Each faculty has a title:
88
89        >>> myfac.title
90        u'Unnamed Faculty'
91
92
93   .. attribute:: title_prefix
94
95      (string) The prefix of a faculty.
96
97      Each faculty has a title prefix, which specifies the kind of
98      institution:
99
100        >>> myfac.title_prefix
101        u'faculty'
102
103
104   .. attribute:: code
105
106      (string) An internally used unique code string.
107
108      Each faculty holds a code, which might be a shortcut or
109      abbreviation of the real faculty name. By default the code is
110      ``NA`` (=not assigned):
111
112        >>> myfac.code
113        u'NA'
114
115
116Utilities
117=========
118
119:class:`FacultyFactory`
120--------------------------
121
122.. class:: FacultyFactory()
123
124   .. attribute:: grok.name(u'waeup.Faculty')
125
126   .. attribute:: grok.implements(IFactory)
127
128   A named utility to deliver new instances of :class:`Faculty`
129   without the need to import the implementation before:
130
131     >>> from zope.component import createObject
132     >>> myfaculty = createObject(u'waeup.Faculty')
133     >>> myfaculty
134     <waeup.sirp.university.faculty.Faculty object at 0x...>
135
136   The factory complies with the specifications from the
137   :class:`IFactory` insterface:
138
139     >>> from zope.interface.verify import verifyClass
140     >>> from zope.component.interfaces import IFactory
141     >>> from waeup.sirp.university.faculty import FacultyFactory
142     >>> verifyClass(IFactory, FacultyFactory)
143     True
144
145   This means also, that we can get the interfaces of the created
146   object from the factory:
147
148     >>> faculty_factory = FacultyFactory()
149     >>> faculty_factory.getInterfaces()
150     <implementedBy waeup.sirp.university.faculty.Faculty>
151
152
153Examples:
154=========
155
156We can create faculties:
157
158    >>> from waeup.sirp.university.faculty import Faculty
159    >>> myfaculty = Faculty()
160    >>> myfaculty
161    <waeup.sirp.university.faculty.Faculty object at 0x...>
162
163Another way to create faculties is by asking for a factory called
164``waeup.Faculty``. Now we can create a factory without importing a
165class:
166
167    >>> from zope.component import createObject
168    >>> myfaculty = createObject(u'waeup.Faculty')
169    >>> myfaculty
170    <waeup.sirp.university.faculty.Faculty object at 0x...>
171
172Faculty attributes
173==================
174
175Faculties have the attributes required by the `IFaculty` interface:
176
177    >>> from waeup.sirp.university.interfaces import IFaculty
178    >>> IFaculty.providedBy(myfaculty)
179    True
180
181    >>> from zope.interface.verify import verifyObject
182    >>> verifyObject(IFaculty, myfaculty)
183    True
184
185Each of the following attributes is mandatory.
186
187`title`
188-------
189
190Each faculty has a title:
191
192    >>> myfaculty.title
193    u'Unnamed Faculty'
194
195`title_prefix`
196--------------
197
198Each faculty has a title prefix, which specifies the kind of
199institution:
200
201    >>> myfaculty.title_prefix
202    u'faculty'
203
204`code`
205------
206
207Each faculty holds a code, which might be a shortcut or abbreviation
208of the real faculty name. By default the code is ``NA`` (=not assigned):
209
210    >>> myfaculty.code
211    u'NA'
Note: See TracBrowser for help on using the repository browser.