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

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