Changeset 12857


Ignore:
Timestamp:
15 Apr 2015, 14:28:46 (10 years ago)
Author:
Henrik Bettermann
Message:

Documentation work in progress.

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/docs/source/userdocs/datacenter.rst

    r12829 r12857  
    33Data Center
    44***********
     5
     6.. contents::
     7
     8Introduction
     9============
     10
     11Most web portals store their data in a relational database like PostgreSQL, MySQL or Oracle. A relational database is organized in tables of rows and columns, with a unique key for each row. Each data entity gets its own table. Rows in tables can be linked to rows in other tables by storing the unique key of the row to which it should be linked. This sounds quite simple. Many computer users are familiar with this kind of data storage because they are used to spreadsheet programmes like Excel oder Calc which also organize data in tables.
     12
     13Kofa's persistent data are stored in a native object database designed for the Python programming language, the so-called ZODB_. An object database stores objects with attributes and not records as rows with columns in tables. These persistent objects can hold any kind of information in attributes and must not adhere to a specific schema like records in tables of a relational database.
     14
     15The ZODB_ also supports a hierarchical, treelike storage of objects. Objects can contain other objects if they are declared as containers. Objects are stored like folders and files in a filesystem. This makes the object handling very fast and transparent because we can access objects, or more precisely views of objects, by indicating their path in the database, i.e. by traversing the database tree to find an object. Furthermore, we are accessing the views of objects through a web browser by entering a URL (Uniform Resource Locator). This publication path corresponds more or less to the traversal path of our objects. In Kofa the path always contains the object identifiers of all objects which are passed when traversing the database tree. Example:
     16
     17https://kofa-demo.waeup.org/students/K1000000/studycourse/100/DCO
     18
     19is the URL which requests a display view of a course ticket with id 'DCO'. This object is stored in a study level container object with id '100', stored in a study course container object with id 'studycourse', stored in the student container object with id 'K1000000', stored in the students root container, stored in the root container of the application, stored in the root of the database itself.
     20
     21This kind of storage requires that each object gets a unique object identifier (object id) within its container. The id string is visible in the browser address bar. Though it's technically possible for ids to contain spaces or slashes we do not allow these kinds of special characters in object ids to facilitate the readability of URLs.
     22
     23Administrators of web portals, which store their data in relational databases, are used to getting direct access to the portal's database. There are even tools to handle the administration of these databases over the Internet, like phpMyAdmin or phpPgAdmin to handle MySQL or PostgreSQL databases respectively. These user interfaces bypass the portals' user interfaces and give direct access to the database. They allow to easily import or export (dump) data tables or the entire database structure into CSV or SQL files. What at first sight appears to be very helpful and administration-friendly proves to be very dangerous on closer inspection. Data structures can be easily damaged or destroyed, or data can be easily manipulated by circumventing the portal's security machinery or logging system. Kofa does not provide any external user interface to access the ZODB directly, neither for viewing nor for editing data. This includes also the export and import of sets of data. Exports and imports are handled via the Kofa user interface itself. This is called batch processing which means either producing CSV files (comma-separated values) from portal data (export) or processing CSV files in order to add, update or remove portal data (import). Main premise of Kofa's batch processing technology is that the data stored in the ZODB can be specifically backed up and restored by exporting and importing data. But that's not all. Batch processors can do much more. They are an integral part of the student registration management.
     24
     25Data Export
     26===========
     27
     28Regular data exporters (1) collect objects from specific containers, (2) iterate over the collected objects, (3) extract and mangle information from each object, (4) write the information of each object into a row of a CSV file and (5) finally provide the file for download. The CSV file is neither stored in the database nor archived in the filesystem. (3) and (4) is a flattening of the hierarchical data structure, i.e. a mapping of objects to flat relational data stored in a CSV table. The extracted information must not necessarily be based only on static attributes of the collected object. The data, finally stored in the CSV file, can also be derived from parent or child objects, or dynamically computed by the object's methods and property attributes. These methods and properties can retrieve information from everywhere in the portal's database.
     29
     30.. autoclass:: waeup.kofa.university.export.FacultyExporter()
     31  :noindex:
     32
     33  .. autoattribute:: waeup.kofa.university.export.FacultyExporter.fields
     34  .. autoattribute:: waeup.kofa.university.export.FacultyExporter.title
     35
     36  .. automethod:: waeup.kofa.university.export.FacultyExporter.mangle_value()
     37
     38
     39
     40
     41Data Import
     42===========
     43
     44Logging
     45=======
     46
     47
     48
     49
     50
     51
     52
     53.. _ZODB: http://www.zodb.org/
  • main/waeup.kofa/trunk/src/waeup/kofa/university/export.py

    r10185 r12857  
    2525
    2626class FacultyExporter(grok.GlobalUtility, ExporterBase):
    27     """Exporter for faculties.
     27    """The FacultyExporter exports all faculties in the 'faculties'
     28    container. This is the only place where faculties are stored.
    2829    """
    2930    grok.implements(ICSVExporter)
    3031    grok.name('faculties')
    3132
    32     #: Fieldnames considered by this exporter
    3333    fields = ('code', 'title', 'title_prefix', 'users_with_local_roles')
    3434
    35     #: The title under which this exporter will be displayed
    3635    title = _(u'Faculties')
    3736
    3837    def mangle_value(self, value, name, context=None):
    39         """Hook for mangling values in derived classes
     38        """The users_with_local_roles column contains Python expression like:
     39
     40        ``[{'user_name': u'bob', 'local_role': u'bobsrole'},
     41        {'user_name': u'anna', 'local_role': u'annasrole'}]``
    4042        """
    4143        if name == 'users_with_local_roles':
    4244            value = []
    4345            role_map = IPrincipalRoleMap(context)
    44             for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
     46            for local_role, user_name, setting in \
     47                role_map.getPrincipalsAndRoles():
    4548                value.append({'user_name':user_name,'local_role':local_role})
    4649        return super(FacultyExporter, self).mangle_value(
     
    4952    def export(self, faculties, filepath=None):
    5053        """Export `faculties`, an iterable, as CSV file.
    51 
    5254        If `filepath` is ``None``, a raw string with CSV data is returned.
    5355        """
     
    5961    def export_all(self, site, filepath=None):
    6062        """Export faculties in facultycontainer into filepath as CSV data.
    61 
    6263        If `filepath` is ``None``, a raw string with CSV data is returned.
    6364        """
     
    7576        'users_with_local_roles')
    7677
    77     #: The title under which this exporter will be displayed
    7878    title = _(u'Departments')
    7979
     
    9090    def export_all(self, site, filepath=None):
    9191        """Export departments in faculty into filepath as CSV data.
    92 
    9392        If `filepath` is ``None``, a raw string with CSV data is returned.
    9493        """
     
    115114
    116115    def mangle_value(self, value, name, context=None):
    117         """Hook for mangling values in derived classes
     116        """
    118117        """
    119118        if name == 'users_with_local_roles':
    120119            value = []
    121120            role_map = IPrincipalRoleMap(context)
    122             for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
     121            for local_role, user_name, setting in \
     122                role_map.getPrincipalsAndRoles():
    123123                value.append({'user_name':user_name,'local_role':local_role})
    124124        elif name == 'faculty_code':
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py

    r12811 r12857  
    437437
    438438    def mangle_value(self, value, name, context=None):
    439         """Hook for mangling values in derived classes
     439        """Hook for mangling values in derived classes.
    440440        """
    441441        if isinstance(value, bool):
Note: See TracChangeset for help on using the changeset viewer.