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

Last change on this file since 5109 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: 3.8 KB
RevLine 
[4920]1:mod:`waeup.sirp.university.department` -- Departments
2******************************************************
[4252]3
[4920]4.. module:: waeup.sirp.university.department
[4326]5
6Components that represent university departments.
7
[4252]8:Test-Layer: unit
9
[4326]10Before we can create departments, we have to grok the :mod:`waeup`
[4257]11package. This happens automatically in real-world use:
12
13    >>> import grok
14    >>> grok.testing.grok('waeup')
15
[4252]16
[4326]17Content Classes (models and containers)
18=======================================
[4252]19
20
[4326]21:class:`Department`
22-------------------
[4252]23
[4326]24.. class:: Department(title=u'Unnamed Department'[, title_prefix=u'department' [, code=u"NA"]])
[4252]25
[4326]26   Create a representation of a university department:
[4252]27
[4920]28     >>> from waeup.sirp.university.department import Department
[4326]29     >>> mydept = Department()
30     >>> mydept
[4920]31     <waeup.sirp.university.department.Department object at 0x...>
[4252]32
[4326]33   Another way to create :class:`Department` instances is by asking
[4920]34   for a factory called ``waeup.sirp.Department``. This way we can create a
[4326]35   department without importing a class:
[4252]36
[4326]37     >>> from zope.component import createObject
38     >>> mydept = createObject(u'waeup.Department')
39     >>> mydept
[4920]40     <waeup.sirp.university.department.Department object at 0x...>
[4252]41
[4326]42   :class:`Department` instances have the attributes required by the
43   `IDepartment` interface:
[4252]44
[5005]45     >>> from waeup.sirp.university.interfaces import IDepartment
[4326]46     >>> IDepartment.providedBy(mydept)
47     True
[4252]48
[4326]49     >>> from zope.interface.verify import verifyObject
50     >>> verifyObject(IDepartment, mydept)
51     True
[4252]52
53
[4326]54   .. attribute:: title
[4252]55
[4326]56      (string) The title of a department.
[4252]57
[4326]58      Each department has a title:
[4252]59
[4326]60        >>> mydept.title
61        u'Unnamed Department'
[4252]62
[4258]63
[4326]64   .. attribute:: title_prefix
[4258]65
[4326]66      (string) The prefix of a department.
[4258]67
[4326]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
[4920]94        <waeup.sirp.university.coursecontainer.CourseContainer object at 0x...>
[4326]95
[4327]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
[4920]105        <waeup.sirp...certificatecontainer.CertificateContainer object at 0x...>
[4327]106
[4372]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
[4920]125     <waeup.sirp.university.department.Department object at 0x...>
[4372]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
[4920]132     >>> from waeup.sirp.university.department import DepartmentFactory
[4372]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()
[4920]141     <implementedBy waeup.sirp.university.department.Department>
Note: See TracBrowser for help on using the repository browser.