1 | :mod:`waeup.university.department` -- Departments |
---|
2 | ************************************************* |
---|
3 | |
---|
4 | .. module:: waeup.university.department |
---|
5 | |
---|
6 | Components that represent university departments. |
---|
7 | |
---|
8 | :Test-Layer: unit |
---|
9 | |
---|
10 | Before we can create departments, we have to grok the :mod:`waeup` |
---|
11 | package. This happens automatically in real-world use: |
---|
12 | |
---|
13 | >>> import grok |
---|
14 | >>> grok.testing.grok('waeup') |
---|
15 | |
---|
16 | |
---|
17 | Content Classes (models and containers) |
---|
18 | ======================================= |
---|
19 | |
---|
20 | |
---|
21 | :class:`Department` |
---|
22 | ------------------- |
---|
23 | |
---|
24 | .. class:: Department(title=u'Unnamed Department'[, title_prefix=u'department' [, code=u"NA"]]) |
---|
25 | |
---|
26 | Create a representation of a university department: |
---|
27 | |
---|
28 | >>> from waeup.university.department import Department |
---|
29 | >>> mydept = Department() |
---|
30 | >>> mydept |
---|
31 | <waeup.university.department.Department object at 0x...> |
---|
32 | |
---|
33 | Another way to create :class:`Department` instances is by asking |
---|
34 | for a factory called ``waeup.Department``. This way we can create a |
---|
35 | department without importing a class: |
---|
36 | |
---|
37 | >>> from zope.component import createObject |
---|
38 | >>> mydept = createObject(u'waeup.Department') |
---|
39 | >>> mydept |
---|
40 | <waeup.university.department.Department object at 0x...> |
---|
41 | |
---|
42 | :class:`Department` instances have the attributes required by the |
---|
43 | `IDepartment` interface: |
---|
44 | |
---|
45 | >>> from waeup.interfaces import IDepartment |
---|
46 | >>> IDepartment.providedBy(mydept) |
---|
47 | True |
---|
48 | |
---|
49 | >>> from zope.interface.verify import verifyObject |
---|
50 | >>> verifyObject(IDepartment, mydept) |
---|
51 | True |
---|
52 | |
---|
53 | |
---|
54 | .. attribute:: title |
---|
55 | |
---|
56 | (string) The title of a department. |
---|
57 | |
---|
58 | Each department has a title: |
---|
59 | |
---|
60 | >>> mydept.title |
---|
61 | u'Unnamed Department' |
---|
62 | |
---|
63 | |
---|
64 | .. attribute:: title_prefix |
---|
65 | |
---|
66 | (string) The prefix of a department. |
---|
67 | |
---|
68 | Each department has a title prefix, which specifies the kind of |
---|
69 | institution: |
---|
70 | |
---|
71 | >>> mydept.title_prefix |
---|
72 | u'department' |
---|
73 | |
---|
74 | |
---|
75 | .. attribute:: code |
---|
76 | |
---|
77 | (string) An internally used unique code string. |
---|
78 | |
---|
79 | Each department holds a code, which might be a shortcut or |
---|
80 | abbreviation of the real department name. By default the code is |
---|
81 | ``NA`` (=not assigned): |
---|
82 | |
---|
83 | >>> mydept.code |
---|
84 | u'NA' |
---|
85 | |
---|
86 | |
---|
87 | .. attribute:: courses |
---|
88 | |
---|
89 | (ICourseContainer instance) A container for courses. |
---|
90 | |
---|
91 | Each department has a courses container: |
---|
92 | |
---|
93 | >>> mydept.courses |
---|
94 | <waeup.university.coursecontainer.CourseContainer object at 0x...> |
---|
95 | |
---|