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

Last change on this file since 6974 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: 3.7 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
[5140]8.. :doctest:
9.. :layer: waeup.sirp.testing.WAeUPSIRPUnitTestLayer
[4252]10
[4326]11Content Classes (models and containers)
12=======================================
[4252]13
14
[4326]15:class:`Department`
16-------------------
[4252]17
[4326]18.. class:: Department(title=u'Unnamed Department'[, title_prefix=u'department' [, code=u"NA"]])
[4252]19
[4326]20   Create a representation of a university department:
[4252]21
[4920]22     >>> from waeup.sirp.university.department import Department
[4326]23     >>> mydept = Department()
24     >>> mydept
[4920]25     <waeup.sirp.university.department.Department object at 0x...>
[4252]26
[4326]27   Another way to create :class:`Department` instances is by asking
[4920]28   for a factory called ``waeup.sirp.Department``. This way we can create a
[4326]29   department without importing a class:
[4252]30
[4326]31     >>> from zope.component import createObject
32     >>> mydept = createObject(u'waeup.Department')
33     >>> mydept
[4920]34     <waeup.sirp.university.department.Department object at 0x...>
[4252]35
[4326]36   :class:`Department` instances have the attributes required by the
37   `IDepartment` interface:
[4252]38
[5005]39     >>> from waeup.sirp.university.interfaces import IDepartment
[4326]40     >>> IDepartment.providedBy(mydept)
41     True
[4252]42
[4326]43     >>> from zope.interface.verify import verifyObject
44     >>> verifyObject(IDepartment, mydept)
45     True
[4252]46
47
[4326]48   .. attribute:: title
[4252]49
[4326]50      (string) The title of a department.
[4252]51
[4326]52      Each department has a title:
[4252]53
[4326]54        >>> mydept.title
55        u'Unnamed Department'
[4252]56
[4258]57
[4326]58   .. attribute:: title_prefix
[4258]59
[4326]60      (string) The prefix of a department.
[4258]61
[4326]62      Each department has a title prefix, which specifies the kind of
63      institution:
64
65        >>> mydept.title_prefix
66        u'department'
67
68
69   .. attribute:: code
70
71      (string) An internally used unique code string.
72
73      Each department holds a code, which might be a shortcut or
74      abbreviation of the real department name. By default the code is
75      ``NA`` (=not assigned):
76
77        >>> mydept.code
78        u'NA'
79
80
81   .. attribute:: courses
82
83      (ICourseContainer instance) A container for courses.
84
85      Each department has a courses container:
86
87        >>> mydept.courses
[4920]88        <waeup.sirp.university.coursecontainer.CourseContainer object at 0x...>
[4326]89
[4327]90
91   .. attribute:: certificates
92
93      (ICertificateContainer instance) A container for certificates.
94
95      Each department has a certificate container, that holds the
96      descrtiptions of certificates the department has:
97
98        >>> mydept.certificates
[4920]99        <waeup.sirp...certificatecontainer.CertificateContainer object at 0x...>
[4327]100
[4372]101Utilities
102=========
103
104:class:`DepartmentFactory`
105--------------------------
106
107.. class:: DepartmentFactory()
108
109   .. attribute:: grok.name(u'waeup.Department')
110
111   .. attribute:: grok.implements(IFactory)
112
113   A named utility to deliver new instances of :class:`Department`
114   without the need to import the implementation before:
115
116     >>> from zope.component import createObject
117     >>> mydepartment = createObject(u'waeup.Department')
118     >>> mydepartment
[4920]119     <waeup.sirp.university.department.Department object at 0x...>
[4372]120
121   The factory complies with the specifications from the
122   :class:`IFactory` insterface:
123
124     >>> from zope.interface.verify import verifyClass
125     >>> from zope.component.interfaces import IFactory
[4920]126     >>> from waeup.sirp.university.department import DepartmentFactory
[4372]127     >>> verifyClass(IFactory, DepartmentFactory)
128     True
129
130   This means also, that we can get the interfaces of the created
131   object from the factory:
132
133     >>> department_factory = DepartmentFactory()
134     >>> department_factory.getInterfaces()
[4920]135     <implementedBy waeup.sirp.university.department.Department>
Note: See TracBrowser for help on using the repository browser.