source: main/waeup.sirp/trunk/src/waeup/sirp/university/department.txt @ 4978

Last change on this file since 4978 was 4920, checked in by uli, 15 years ago

Make unit tests run again with the new package layout.

File size: 3.8 KB
Line 
1:mod:`waeup.sirp.university.department` -- Departments
2******************************************************
3
4.. module:: waeup.sirp.university.department
5
6Components that represent university departments.
7
8:Test-Layer: unit
9
10Before we can create departments, 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
16
17Content 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.sirp.university.department import Department
29     >>> mydept = Department()
30     >>> mydept
31     <waeup.sirp.university.department.Department object at 0x...>
32
33   Another way to create :class:`Department` instances is by asking
34   for a factory called ``waeup.sirp.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.sirp.university.department.Department object at 0x...>
41
42   :class:`Department` instances have the attributes required by the
43   `IDepartment` interface:
44
45     >>> from waeup.sirp.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.sirp.university.coursecontainer.CourseContainer object at 0x...>
95
96
97   .. attribute:: certificates
98
99      (ICertificateContainer instance) A container for certificates.
100
101      Each department has a certificate container, that holds the
102      descrtiptions of certificates the department has:
103
104        >>> mydept.certificates
105        <waeup.sirp...certificatecontainer.CertificateContainer object at 0x...>
106
107Utilities
108=========
109
110:class:`DepartmentFactory`
111--------------------------
112
113.. class:: DepartmentFactory()
114
115   .. attribute:: grok.name(u'waeup.Department')
116
117   .. attribute:: grok.implements(IFactory)
118
119   A named utility to deliver new instances of :class:`Department`
120   without the need to import the implementation before:
121
122     >>> from zope.component import createObject
123     >>> mydepartment = createObject(u'waeup.Department')
124     >>> mydepartment
125     <waeup.sirp.university.department.Department object at 0x...>
126
127   The factory complies with the specifications from the
128   :class:`IFactory` insterface:
129
130     >>> from zope.interface.verify import verifyClass
131     >>> from zope.component.interfaces import IFactory
132     >>> from waeup.sirp.university.department import DepartmentFactory
133     >>> verifyClass(IFactory, DepartmentFactory)
134     True
135
136   This means also, that we can get the interfaces of the created
137   object from the factory:
138
139     >>> department_factory = DepartmentFactory()
140     >>> department_factory.getInterfaces()
141     <implementedBy waeup.sirp.university.department.Department>
Note: See TracBrowser for help on using the repository browser.