1 | The waeup package |
---|
2 | ******************** |
---|
3 | |
---|
4 | :Test-Layer: unit |
---|
5 | |
---|
6 | A portal software for student registration. |
---|
7 | |
---|
8 | Prerequisites |
---|
9 | ============= |
---|
10 | |
---|
11 | Before we can work with the environment, we have to register all the |
---|
12 | utilities, adapters, etc. We grok the `waeup` package to do that:: |
---|
13 | |
---|
14 | >>> import grok |
---|
15 | >>> grok.testing.grok('waeup') |
---|
16 | |
---|
17 | Universities |
---|
18 | ============ |
---|
19 | |
---|
20 | ``University`` objects are the base of all functionality provided by |
---|
21 | this package. They contain all facilities of a university. |
---|
22 | |
---|
23 | We can easily create universities:: |
---|
24 | |
---|
25 | >>> from waeup.app import University |
---|
26 | >>> u = University() |
---|
27 | >>> u |
---|
28 | <waeup.app.University object at 0x...> |
---|
29 | |
---|
30 | Universities have a name. |
---|
31 | |
---|
32 | >>> u.name |
---|
33 | u'Sample University' |
---|
34 | |
---|
35 | Universities are basically also containers for faculties, students and |
---|
36 | hostels:: |
---|
37 | |
---|
38 | >>> u.faculties |
---|
39 | <waeup.university.facultycontainer.FacultyContainer object at 0x...> |
---|
40 | |
---|
41 | >>> u['students'] |
---|
42 | <waeup.student.studentcontainer.StudentContainer object at 0x...> |
---|
43 | |
---|
44 | >>> u['hostels'] |
---|
45 | <waeup.hostel.hostelcontainer.HostelContainer object at 0x...> |
---|
46 | |
---|
47 | We can export universities. For this we lookup an appropriate exporter |
---|
48 | first:: |
---|
49 | |
---|
50 | >>> from waeup.interfaces import IWAeUPExporter |
---|
51 | >>> exporter = IWAeUPExporter(u) |
---|
52 | >>> exporter |
---|
53 | <waeup.utils.importexport.Exporter object at 0x...> |
---|
54 | |
---|
55 | Now we can trigger the export:: |
---|
56 | |
---|
57 | >>> exporter.export(u) |
---|
58 | <cStringIO.StringO object at 0x...> |
---|
59 | |
---|
60 | We can also get an XML representation as file. If we do not provide a |
---|
61 | filepath, we will get an instance of `cStringIO.StringIO`, i.e. a |
---|
62 | memory file:: |
---|
63 | |
---|
64 | >>> from waeup.interfaces import IWAeUPXMLExporter |
---|
65 | >>> exporter = IWAeUPXMLExporter(u) |
---|
66 | >>> f = exporter.export(u) |
---|
67 | >>> f |
---|
68 | <cStringIO.StringO object at 0x...> |
---|
69 | |
---|
70 | >>> print f.read() |
---|
71 | <?xml version="1.0" encoding="UTF-8"?> |
---|
72 | <waeupdata> |
---|
73 | <object type="waeup.app.University"> |
---|
74 | <attribute name="name" type="unicode"> |
---|
75 | Sample University |
---|
76 | </attribute> |
---|
77 | </object> |
---|
78 | </waeupdata> |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | Faculties |
---|
83 | ========= |
---|
84 | |
---|
85 | Faculties are containers for departments. They are intended to be |
---|
86 | managed by universities. |
---|
87 | |
---|
88 | We can create faculties easily:: |
---|
89 | |
---|
90 | >>> from waeup.university.faculty import Faculty |
---|
91 | >>> f = Faculty() |
---|
92 | >>> f |
---|
93 | <waeup.university.faculty.Faculty object at 0x...> |
---|
94 | |
---|
95 | Also faculties want to be named:: |
---|
96 | |
---|
97 | >>> f.name |
---|
98 | u'Unnamed Faculty' |
---|
99 | |
---|
100 | Departments |
---|
101 | =========== |
---|
102 | |
---|