Changeset 4326 for waeup/branches/ulif-rewrite/src
- Timestamp:
- 21 Jun 2009, 00:05:38 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/department.txt
r4258 r4326 1 Departments 2 *********** 1 :mod:`waeup.university.department` -- Departments 2 ************************************************* 3 4 .. module:: waeup.university.department 5 6 Components that represent university departments. 3 7 4 8 :Test-Layer: unit 5 9 6 Creating departments 7 ==================== 8 9 Before we can create departments, we have to grok the `waeup` 10 Before we can create departments, we have to grok the :mod:`waeup` 10 11 package. This happens automatically in real-world use: 11 12 … … 13 14 >>> grok.testing.grok('waeup') 14 15 15 We can create departments:16 16 17 >>> from waeup.university.department import Department 18 >>> mydept = Department() 19 >>> mydept 20 <waeup.university.department.Department object at 0x...> 17 Content Classes (models and containers) 18 ======================================= 21 19 22 Another way to create departments is by asking for a factory called23 ``waeup.Department``. This way we can create a department without24 importing a class:25 20 26 >>> from zope.component import createObject 27 >>> mydept = createObject(u'waeup.Department') 28 >>> mydept 29 <waeup.university.department.Department object at 0x...> 21 :class:`Department` 22 ------------------- 30 23 31 Department attributes 32 ===================== 24 .. class:: Department(title=u'Unnamed Department'[, title_prefix=u'department' [, code=u"NA"]]) 33 25 34 Departments have the attributes required by the `IDepartment` interface:26 Create a representation of a university department: 35 27 36 >>> from waeup.interfaces import IDepartment 37 >>> IDepartment.providedBy(mydept) 38 True 28 >>> from waeup.university.department import Department 29 >>> mydept = Department() 30 >>> mydept 31 <waeup.university.department.Department object at 0x...> 39 32 40 >>> from zope.interface.verify import verifyObject41 >>> verifyObject(IDepartment, mydept)42 True33 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: 43 36 44 Each of the following attributes is mandatory. 37 >>> from zope.component import createObject 38 >>> mydept = createObject(u'waeup.Department') 39 >>> mydept 40 <waeup.university.department.Department object at 0x...> 45 41 46 `title` 47 ------- 42 :class:`Department` instances have the attributes required by the 43 `IDepartment` interface: 48 44 49 Each department has a title: 45 >>> from waeup.interfaces import IDepartment 46 >>> IDepartment.providedBy(mydept) 47 True 50 48 51 >>> mydept.title 52 u'Unnamed Department' 49 >>> from zope.interface.verify import verifyObject 50 >>> verifyObject(IDepartment, mydept) 51 True 53 52 54 `title_prefix`55 --------------56 53 57 Each department has a title prefix, which specifies the kind of 58 institution: 54 .. attribute:: title 59 55 60 >>> mydept.title_prefix 61 u'department' 56 (string) The title of a department. 62 57 63 `code` 64 ------ 58 Each department has a title: 65 59 66 Each department holds a code, which might be a shortcut or 67 abbreviation of the real department name. By default the code is ``NA`` 68 (=not assigned): 60 >>> mydept.title 61 u'Unnamed Department' 69 62 70 >>> mydept.code71 u'NA'72 63 73 `courses` 74 --------- 64 .. attribute:: title_prefix 75 65 76 Each department has a courses container: 66 (string) The prefix of a department. 77 67 78 >>> mydept.courses 79 <waeup.university.coursecontainer.CourseContainer object at 0x...> 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
Note: See TracChangeset for help on using the changeset viewer.