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

Last change on this file since 6785 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
RevLine 
[4920]1The waeup.sirp package
2**********************
[3521]3
[5140]4.. :doctest:
5.. :layer: waeup.sirp.testing.WAeUPSIRPUnitTestLayer
[3521]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
[4920]17  >>> from waeup.sirp.app import University
[3521]18  >>> u = University()
19  >>> u
[4920]20  <waeup.sirp.app.University object at 0x...>
[3521]21
22Universities have a name.
23
24  >>> u.name
[4789]25  u'Sample University'
[3521]26
[4789]27Universities are basically also containers for faculties, students and
28hostels::
[3521]29
[4789]30  >>> u['faculties']
[4920]31  <waeup.sirp.university.facultycontainer.FacultyContainer object at 0x...>
[4789]32
33  >>> u['students']
[6621]34  <waeup.sirp.students.container.StudentsContainer object at 0x...>
[4789]35
36We can export universities. For this we lookup an appropriate exporter
37first::
38
[4920]39  >>> from waeup.sirp.interfaces import IWAeUPExporter
[4789]40  >>> exporter = IWAeUPExporter(u)
41  >>> exporter
[4920]42  <waeup.sirp.utils.importexport.Exporter object at 0x...>
[4789]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
[4920]53  >>> from waeup.sirp.interfaces import IWAeUPXMLExporter
[4789]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
[3521]67Faculties
68=========
69
70Faculties are containers for departments. They are intended to be
71managed by universities.
72
73We can create faculties easily::
74
[4920]75  >>> from waeup.sirp.university.faculty import Faculty
[3521]76  >>> f = Faculty()
77  >>> f
[4920]78  <waeup.sirp.university.faculty.Faculty object at 0x...>
[3521]79
80Also faculties want to be named::
81
[4789]82  >>> f.title
[3521]83  u'Unnamed Faculty'
84
85Departments
86===========
87
[5072]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.