Ignore:
Timestamp:
17 Apr 2015, 14:43:42 (10 years ago)
Author:
Henrik Bettermann
Message:

More documentation.

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

Legend:

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

    r12859 r12861  
    2828Regular 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) means a flattening of the hierarchical data structure, i.e. a mapping of objects to flat relational data to be 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.
    2929
    30 In the following we list all exporter classes including two attributes and a method description. The `fields` attribute contain the column titles of the export file. These are not necessarily only attributes of the exported objects. The `title` attribute unveils the name of the exporter under which this exporter will be displayed in the user interface. The `mangle_value()` method shows how some of fields are being dynamically computed.
     30In the following we list all exporter classes including two attributes and a method description. The `fields` attribute contain the column titles of the export file. These are not necessarily only attributes of the exported objects.
     31
     32.. note::
     33
     34  The list of exported columns usually underlies heavy customizations. In the Kofa base package only very fiew columns are being exported. In some Kofa custom packages tons of data are being gathered from applicants and students and the number of columns increase accordingly.
     35
     36The `title` attribute unveils the name of the exporter under which this exporter will be displayed in the user interface. The `mangle_value()` method shows how some of fields are being dynamically computed.
    3137
    3238Regular Exporters
     
    7783
    7884
    79 .. autoclass:: waeup.kofa.applicants.export.ApplicantsContainerExporter()
    80   :noindex:
    81 
    82   .. autoattribute:: waeup.kofa.applicants.export.ApplicantsContainerExporter.fields
    83   .. autoattribute:: waeup.kofa.applicants.export.ApplicantsContainerExporter.title
    84 
    85 .. autoclass:: waeup.kofa.applicants.export.ApplicantExporter()
    86   :noindex:
    87 
    88   .. autoattribute:: waeup.kofa.applicants.export.ApplicantExporter.fields
    89   .. autoattribute:: waeup.kofa.applicants.export.ApplicantExporter.title
    90   .. automethod:: waeup.kofa.applicants.export.ApplicantExporter.mangle_value()
    91 
    9285.. autoclass:: waeup.kofa.accesscodes.export.AccessCodeBatchExporter()
    9386  :noindex:
     
    115108  .. autoattribute:: waeup.kofa.hostels.export.BedExporter.title
    116109
     110Application Data Exporters
     111--------------------------
     112
     113.. autoclass:: waeup.kofa.applicants.export.ApplicantsContainerExporter()
     114  :noindex:
     115
     116  .. autoattribute:: waeup.kofa.applicants.export.ApplicantsContainerExporter.fields
     117  .. autoattribute:: waeup.kofa.applicants.export.ApplicantsContainerExporter.title
     118
     119.. autoclass:: waeup.kofa.applicants.export.ApplicantExporter()
     120  :noindex:
     121
     122  .. autoattribute:: waeup.kofa.applicants.export.ApplicantExporter.fields
     123  .. autoattribute:: waeup.kofa.applicants.export.ApplicantExporter.title
     124  .. automethod:: waeup.kofa.applicants.export.ApplicantExporter.mangle_value()
    117125
    118126Student Data Exporters
    119127----------------------
    120128
     129When starting a Student Data Exporter in the Data Center all student records will be taken into consideration, no matter what or where a student is studying. The exporter can also be started 'locally' at various levels in the academic section. Starting one of the exporters e.g. at faculty or department level means that only the data of students are exported who study in this faculty or department respectively. The exporter can also be started at certificate level. Then only the data of students, who are studying the named study course, will be taken into account. At course level the data of those students are being exported who have attended or taken this specific course.
     130
     131Student Data Exporter can be further configured through a configuration page. Search parameters like the student's current level, current session and current study mode  can be set to filter sets of students in order to decrease the size of the export file. The set of filter parameters varies and depends on the 'locatation' from where the exporter is called. A completely different set of filter parameters is provided for courses. In this case the session and level can be selected when the course was taken by the student.
     132
     133.. autoclass:: waeup.kofa.students.export.StudentExporter()
     134  :noindex:
     135
     136  .. autoattribute:: waeup.kofa.students.export.StudentExporter.fields
     137  .. autoattribute:: waeup.kofa.students.export.StudentExporter.title
     138  .. automethod:: waeup.kofa.students.export.StudentExporter.mangle_value()
     139
     140.. autoclass:: waeup.kofa.students.export.StudentStudyCourseExporter()
     141  :noindex:
     142
     143  .. autoattribute:: waeup.kofa.students.export.StudentStudyCourseExporter.fields
     144  .. autoattribute:: waeup.kofa.students.export.StudentStudyCourseExporter.title
     145  .. automethod:: waeup.kofa.students.export.StudentStudyCourseExporter.mangle_value()
     146
     147.. autoclass:: waeup.kofa.students.export.StudentStudyLevelExporter()
     148  :noindex:
     149
     150  .. autoattribute:: waeup.kofa.students.export.StudentStudyLevelExporter.fields
     151  .. autoattribute:: waeup.kofa.students.export.StudentStudyLevelExporter.title
     152  .. automethod:: waeup.kofa.students.export.StudentStudyLevelExporter.mangle_value()
     153
     154.. autoclass:: waeup.kofa.students.export.CourseTicketExporter()
     155  :noindex:
     156
     157  .. autoattribute:: waeup.kofa.students.export.CourseTicketExporter.fields
     158  .. autoattribute:: waeup.kofa.students.export.CourseTicketExporter.title
     159  .. automethod:: waeup.kofa.students.export.CourseTicketExporter.mangle_value()
    121160
    122161Data Import
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/export.py

    r12859 r12861  
    6464
    6565class ApplicantExporter(grok.GlobalUtility, ExporterBase):
    66     """The Applicant Exporter exports all application records (= applicants)
     66    """The Applicant Exporter exports application records (= applicants)
    6767    stored in the database. In contrast to the exporters in the academics
    6868    section this exporter does not iterate over the items of containers
    69     but searches the Applicants Catalog instead.
     69    but searches the :class:`ApplicantsCatalog` instead.
     70
     71    The exporter exports all applicants if started in the Data Center
     72    which means in the context of the `DataCenter` object. The exporter can also
     73    be started 'locally' which means in the context of an `ApplicantsContainer`
     74    container. Then the :meth:`export_filtered()` instead of the
     75    :meth:`export_all()` method is applied which searches for applicants
     76    in the respective container.
    7077    """
    7178    grok.implements(ICSVExporter)
     
    98105    def export(self, applicants, filepath=None):
    99106        """Export `applicants`, an iterable, as CSV file.
    100 
    101107        If `filepath` is ``None``, a raw string with CSV data is returned.
    102108        """
     
    107113
    108114    def export_all(self, site, filepath=None):
    109         """Export applicants into filepath as CSV data.
    110 
     115        """Export all applicants into filepath as CSV data.
    111116        If `filepath` is ``None``, a raw string with CSV data is returned.
    112117        """
     
    122127
    123128    def export_filtered(self, site, filepath=None, **kw):
    124         """Export applicants in container.
    125 
     129        """Export filtered applicants in container denoted by keywords (`kw`).
    126130        If `filepath` is ``None``, a raw string with CSV data should
    127131        be returned.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r12568 r12861  
    5656def get_tickets(students, **kw):
    5757    """Get course tickets of `students`.
    58 
    5958    If code is passed through, filter course tickets
    6059    which belong to this course code and meets level
     
    8988def get_payments(students, paid=False, **kw):
    9089    """Get all payments of `students` within given payment_date period.
    91 
    9290    """
    9391    date_format = '%d/%m/%Y'
     
    146144class StudentExporterBase(ExporterBase):
    147145    """Exporter for students or related objects.
    148 
    149146    This is a baseclass.
    150147    """
     
    158155    def get_filtered(self, site, **kw):
    159156        """Get students from a catalog filtered by keywords.
    160 
    161157        students_catalog is the default catalog. The keys must be valid
    162158        catalog index names.
     
    192188    def get_selected(self, site, selected):
    193189        """Get set of selected students.
    194 
    195190        Returns a simple empty list or a list with `Student`
    196191        objects.
     
    206201    def export(self, values, filepath=None):
    207202        """Export `values`, an iterable, as CSV file.
    208 
    209203        If `filepath` is ``None``, a raw string with CSV data is returned.
    210204        """
     
    216210    def export_all(self, site, filepath=None):
    217211        """Export students into filepath as CSV data.
    218 
    219212        If `filepath` is ``None``, a raw string with CSV data is returned.
    220213        """
     
    226219    def export_filtered(self, site, filepath=None, **kw):
    227220        """Export items denoted by `kw`.
    228 
    229221        If `filepath` is ``None``, a raw string with CSV data should
    230222        be returned.
     
    242234
    243235class StudentExporter(grok.GlobalUtility, StudentExporterBase):
    244     """Exporter for Students.
     236    """The Student Exporter first filters the set of students by searching the
     237    students catalog. Then it exports student base data of this set of students.
    245238    """
    246239    grok.name('students')
    247240
    248     #: Fieldnames considered by this exporter
    249241    fields = tuple(sorted(iface_names(IStudent))) + (
    250242        'password', 'state', 'history', 'certcode', 'is_postgrad',
    251243        'current_level', 'current_session')
    252 
    253     #: The title under which this exporter will be displayed
    254244    title = _(u'Students')
    255245
    256246    def mangle_value(self, value, name, context=None):
     247        """The mangler prepares the history messages and adds a hash symbol at
     248        the end of the phone number to avoid annoying automatic number
     249        transformation by Excel or Calc."""
    257250        if name == 'history':
    258251            value = value.messages
     
    267260
    268261class StudentStudyCourseExporter(grok.GlobalUtility, StudentExporterBase):
    269     """Exporter for StudentStudyCourses.
     262    """The Student Study Course Exporter first filters the set of students
     263    by searching the students catalog. Then it exports the data of the current
     264    study course container of each student from this set. It does
     265    not export their content.
    270266    """
    271267    grok.name('studentstudycourses')
    272268
    273     #: Fieldnames considered by this exporter
    274269    fields = tuple(sorted(iface_names(IStudentStudyCourse))) + ('student_id',)
    275 
    276     #: The title under which this exporter will be displayed
    277270    title = _(u'Student Study Courses')
    278271
     
    281274
    282275    def mangle_value(self, value, name, context=None):
    283         """Treat location values special.
     276        """The mangler determines the certificate code and the student id.
    284277        """
    285278        if name == 'certificate' and value is not None:
     
    295288
    296289class StudentStudyLevelExporter(grok.GlobalUtility, StudentExporterBase):
    297     """Exporter for StudentStudyLevels.
     290    """The Student Study Level Exporter first filters the set of students
     291    by searching the students catalog. Then it exports the data of the student's
     292    study level containers but not their content (course tickets).
     293    The exporter iterates over all objects in the students' ``studycourse``
     294    containers.
    298295    """
    299296    grok.name('studentstudylevels')
    300297
    301     #: Fieldnames considered by this exporter
    302298    fields = tuple(sorted(iface_names(
    303299        IStudentStudyLevel) + ['level'])) + (
    304300        'student_id', 'number_of_tickets','certcode')
    305 
    306     #: The title under which this exporter will be displayed
    307301    title = _(u'Student Study Levels')
    308302
     
    311305
    312306    def mangle_value(self, value, name, context=None):
    313         """Treat location values special.
     307        """The mangler determines the student id, nothing else.
    314308        """
    315309        if name == 'student_id' and context is not None:
     
    321315
    322316class CourseTicketExporter(grok.GlobalUtility, StudentExporterBase):
    323     """Exporter for CourseTickets.
     317    """The Course Ticket  Exporter exports course tickets. Usually,
     318    the exporter first filters the set of students by searching the
     319    students catalog. Then it collects and iterates over all ``studylevel``
     320    containers of the filtered student set and finally
     321    iterates over all items inside these containers.
     322
     323    If the course code is passed through, the exporter uses a different
     324    catalog. It searches for students in the course tickets catalog and
     325    exports those course tickets which belong to the given course code and
     326    also meet level and level_session passed through at the same time.
     327    This happens if the exporter is called at course level in the academics
     328    section.
    324329    """
    325330    grok.name('coursetickets')
    326331
    327     #: Fieldnames considered by this exporter
    328332    fields = tuple(sorted(iface_names(ICourseTicket) +
    329333        ['level', 'code', 'level_session'])) + ('student_id',
    330334        'certcode', 'display_fullname')
    331 
    332     #: The title under which this exporter will be displayed
    333335    title = _(u'Course Tickets')
    334336
     
    337339
    338340    def mangle_value(self, value, name, context=None):
    339         """Treat location values special.
     341        """The mangler determines the student's id and fullname.
    340342        """
    341343        if context is not None:
     
    343345            if name in ('student_id', 'display_fullname') and student is not None:
    344346                value = getattr(student, name, None)
    345             #if name == 'level':
    346             #    value = getattr(context, 'level', lambda: None)
    347             #if name == 'level_session':
    348             #    value = getattr(context, 'level_session', lambda: None)
    349347        return super(
    350348            CourseTicketExporter, self).mangle_value(
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py

    r12857 r12861  
    493493    def close_outfile(self, filepath, outfile):
    494494        """Close outfile.
    495 
    496495        If filepath is None, the contents of outfile is returned.
    497496        """
     
    504503    def get_filtered(self, site, **kw):
    505504        """Get datasets to export filtered by keyword arguments.
    506 
    507505        Returns an iterable.
    508506        """
     
    512510        """Get datasets to export for selected items
    513511        specified by a list of identifiers.
    514 
    515512        Returns an iterable.
    516513        """
     
    519516    def export(self, iterable, filepath=None):
    520517        """Export `iterable` as CSV file.
    521 
    522518        If `filepath` is ``None``, a raw string with CSV data should
    523519        be returned.
     
    528524        """Export all appropriate objects in `site` into `filepath` as
    529525        CSV data.
    530 
    531526        If `filepath` is ``None``, a raw string with CSV data should
    532527        be returned.
     
    535530
    536531    def export_filtered(self, site, filepath=None, **kw):
    537         """Export items denoted by `args` and `kw`.
    538 
     532        """Export items denoted by `kw`.
    539533        If `filepath` is ``None``, a raw string with CSV data should
    540534        be returned.
     
    546540        """Export those items specified by a list of identifiers
    547541        called `selected`.
    548 
    549542        If `filepath` is ``None``, a raw string with CSV data should
    550543        be returned.
Note: See TracChangeset for help on using the changeset viewer.