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

Last change on this file since 6660 was 6622, checked in by Henrik Bettermann, 13 years ago

Add some basic UI stuff to start and to play with.

  • Property svn:eol-style set to native
File size: 3.3 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.students.container.StudentsContainer object at 0x...>
35
36We can export universities. For this we lookup an appropriate exporter
37first::
38
39  >>> from waeup.sirp.interfaces import IWAeUPExporter
40  >>> exporter = IWAeUPExporter(u)
41  >>> exporter
42  <waeup.sirp.utils.importexport.Exporter object at 0x...>
43
44Now we can trigger the export::
45
46  >>> exporter.export()
47  <cStringIO.StringO object at 0x...>
48
49We can also get an XML representation as file. If we do not provide a
50filepath, we will get an instance of `cStringIO.StringIO`, i.e. a
51memory file::
52
53  >>> from waeup.sirp.interfaces import IWAeUPXMLExporter
54  >>> exporter = IWAeUPXMLExporter(u)
55  >>> f = exporter.export()
56  >>> f
57  <cStringIO.StringO object at 0x...>
58
59  >>> print f.read()
60  <?xml version="1.0" encoding="utf-8" ?>
61  <pickle>
62    <initialized_object id="...">
63  ...
64  </pickle>
65
66
67Faculties
68=========
69
70Faculties are containers for departments. They are intended to be
71managed by universities.
72
73We can create faculties easily::
74
75  >>> from waeup.sirp.university.faculty import Faculty
76  >>> f = Faculty()
77  >>> f
78  <waeup.sirp.university.faculty.Faculty object at 0x...>
79
80Also faculties want to be named::
81
82  >>> f.title
83  u'Unnamed Faculty'
84
85Departments
86===========
87
88
89WAeUP SIRP plugins
90==================
91
92waeup.sirp provides an API to 'plugin' components. Things that should
93be setup at creation time of a WAeUP SIRP application can indicate
94that by providing a utility providing IWAeUPSIRPPlugin.
95
96The plugins are looked up by an created app, which then will call the
97``setup()`` method of each plugin.
98
99   >>> from waeup.sirp.interfaces import IWAeUPSIRPPluggable
100   >>> from zope.component import getAdapters, getUtilitiesFor
101   >>> sorted(list(getUtilitiesFor(IWAeUPSIRPPluggable)))
102   [(u'accesscodes', <waeup.sirp.accesscodes...AccessCodePlugin ...)]
103
104
105We can provide a new plugin like this:
106
107   >>> import grok
108   >>> from waeup.sirp.interfaces import IWAeUPSIRPPluggable
109   >>> class MyPlugin(grok.GlobalUtility):
110   ...   grok.implements(IWAeUPSIRPPluggable)
111   ...   def setup(self, site, name, logger):
112   ...     print "Setup was called for"
113   ...     print site
114   ...   def update(self, site, name, logger):
115   ...     pass
116
117When we register the plugin
118
119   >>> grok.testing.grok_component('MyPlugin', MyPlugin)
120   True
121
122and setup a new WAeUP SIRP instance, we will get a message:
123
124   >>> from waeup.sirp.app import University
125   >>> site = University()
126   Setup was called for
127   <waeup.sirp.app.University object at 0x...>
128
129Apparently the plugin can do with the University object whatever it
130likes. That's what plugins are for.
Note: See TracBrowser for help on using the repository browser.