source: main/waeup.sirp/trunk/src/waeup/sirp/README.txt @ 5438

Last change on this file since 5438 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.

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1The waeup.sirp package
2**********************
3
4.. :doctest:
5.. :layer: waeup.sirp.testing.WAeUPSIRPUnitTestLayer
6
7A portal software for student registration.
8
9Universities
10============
11
12``University`` objects are the base of all functionality provided by
13this package.  They contain all facilities of a university.
14
15We can easily create universities::
16
17  >>> from waeup.sirp.app import University
18  >>> u = University()
19  >>> u
20  <waeup.sirp.app.University object at 0x...>
21
22Universities have a name.
23
24  >>> u.name
25  u'Sample University'
26
27Universities are basically also containers for faculties, students and
28hostels::
29
30  >>> u['faculties']
31  <waeup.sirp.university.facultycontainer.FacultyContainer object at 0x...>
32
33  >>> u['students']
34  <waeup.sirp.student.studentcontainer.StudentContainer object at 0x...>
35
36  >>> u['hostels']
37  <waeup.sirp.hostel.hostelcontainer.HostelContainer object at 0x...>
38
39We can export universities. For this we lookup an appropriate exporter
40first::
41
42  >>> from waeup.sirp.interfaces import IWAeUPExporter
43  >>> exporter = IWAeUPExporter(u)
44  >>> exporter
45  <waeup.sirp.utils.importexport.Exporter object at 0x...>
46
47Now we can trigger the export::
48
49  >>> exporter.export()
50  <cStringIO.StringO object at 0x...>
51
52We can also get an XML representation as file. If we do not provide a
53filepath, we will get an instance of `cStringIO.StringIO`, i.e. a
54memory file::
55
56  >>> from waeup.sirp.interfaces import IWAeUPXMLExporter
57  >>> exporter = IWAeUPXMLExporter(u)
58  >>> f = exporter.export()
59  >>> f
60  <cStringIO.StringO object at 0x...>
61
62  >>> print f.read()
63  <?xml version="1.0" encoding="utf-8" ?>
64  <pickle>
65    <initialized_object id="...">
66  ...
67  </pickle>
68
69
70Faculties
71=========
72
73Faculties are containers for departments. They are intended to be
74managed by universities.
75
76We can create faculties easily::
77
78  >>> from waeup.sirp.university.faculty import Faculty
79  >>> f = Faculty()
80  >>> f
81  <waeup.sirp.university.faculty.Faculty object at 0x...>
82
83Also faculties want to be named::
84
85  >>> f.title
86  u'Unnamed Faculty'
87
88Departments
89===========
90
91
92WAeUP SIRP plugins
93==================
94
95waeup.sirp provides an API to 'plugin' components. Things that should
96be setup at creation time of a WAeUP SIRP application can indicate
97that by providing a utility providing IWAeUPSIRPPlugin.
98
99The plugins are looked up by an created app, which then will call the
100``setup()`` method of each plugin.
101
102   >>> from waeup.sirp.interfaces import IWAeUPSIRPPluggable
103   >>> from zope.component import getAdapters, getUtilitiesFor
104   >>> sorted(list(getUtilitiesFor(IWAeUPSIRPPluggable)))
105   [(u'accesscodes', <waeup.sirp.accesscodes...AccessCodePlugin ...)]
106
107
108We can provide a new plugin like this:
109
110   >>> import grok
111   >>> from waeup.sirp.interfaces import IWAeUPSIRPPluggable
112   >>> class MyPlugin(grok.GlobalUtility):
113   ...   grok.implements(IWAeUPSIRPPluggable)
114   ...   def setup(self, site, name, logger):
115   ...     print "Setup was called for"
116   ...     print site
117   ...   def update(self, site, name, logger):
118   ...     pass
119
120When we register the plugin
121
122   >>> grok.testing.grok_component('MyPlugin', MyPlugin)
123   True
124
125and setup a new WAeUP SIRP instance, we will get a message:
126
127   >>> from waeup.sirp.app import University
128   >>> site = University()
129   Setup was called for
130   <waeup.sirp.app.University object at 0x...>
131
132Apparently the plugin can do with the University object whatever it
133likes. That's what plugins are for.
Note: See TracBrowser for help on using the repository browser.