Ignore:
Timestamp:
22 Apr 2015, 19:14:14 (9 years ago)
Author:
Henrik Bettermann
Message:

Start documenting batch processors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/batching.py

    r11891 r12869  
    4444
    4545class FacultyProcessor(BatchProcessor):
    46     """A batch processor for IFaculty objects.
     46    """The Faculty Processor processes faculties in the `faculties` container.
     47    The `FacultyProcessor` class also serves as a baseclass for all other
     48    batch processors in the academic section.
     49
     50    The processor makes some efforts to set local roles.
     51    If new roles are provided, the `updateEntry` method first removes
     52    all existing roles and then sets the new roles as given in the import
     53    file. That means the entire set of local roles is replaced.
    4754    """
    4855    grok.implements(IBatchProcessor)
     
    103110            role_map = IPrincipalRoleMap(obj)
    104111            # Remove all existing local roles.
    105             for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
     112            for local_role, user_name, setting in \
     113                role_map.getPrincipalsAndRoles():
    106114                role_manager.unsetRoleForPrincipal(local_role, user_name)
    107115                notify(LocalRoleSetEvent(
     
    114122                    local_role = rolemap['local_role']
    115123                    role_manager.assignRoleToPrincipal(local_role, user)
    116                     notify(LocalRoleSetEvent(obj, local_role, user, granted=True))
    117                     items_changed += (
    118                         '%s=%s, ' % ('local_roles', '%s|%s' % (user,local_role)))
     124                    notify(LocalRoleSetEvent(
     125                        obj, local_role, user, granted=True))
     126                    items_changed += ('%s=%s, '
     127                        % ('local_roles', '%s|%s' % (user,local_role)))
    119128            row.pop('local_roles')
    120129
     
    151160                if not 'user_name' in rolemap.keys() or not \
    152161                    'local_role' in rolemap.keys():
    153                     errs.append(('local_roles','user_name or local_role missing'))
     162                    errs.append((
     163                        'local_roles','user_name or local_role missing'))
    154164                    return errs, inv_errs, conv_dict
    155165                local_role = rolemap['local_role']
     
    165175
    166176class DepartmentProcessor(FacultyProcessor):
    167     """A batch processor for IDepartment objects.
     177    """The Department Processor works in the same way as the Faculty
     178    Processor. Since department codes are not necessarily unique, it needs the
     179    `faculty_code` to create and update objects.
    168180    """
    169181    grok.implements(IBatchProcessor)
     
    213225
    214226class CertificateProcessor(FacultyProcessor):
    215     """A batch processor for ICertificate objects.
     227    """The Certificate Processor gets the parent object (the
     228    `certificates` attribute of the department container) in two ways.
     229    If both faculty and department codes are provided, `getPartents` uses
     230    these to locate the certificate. If department code or
     231    faculty code are missing, it use the certificates catalog to find the
     232    certificate.
    216233    """
    217234    grok.implements(IBatchProcessor)
     
    270287            return dept.certificates
    271288        # If department code or faculty code is missing,
    272         # use catalog to get parent. Makes only sense in update mode but
    273         # does also work in create mode.
     289        # use catalog to get parent.
    274290        cat = queryUtility(ICatalog, name='certificates_catalog')
    275291        results = list(
     
    296312
    297313class CourseProcessor(CertificateProcessor):
    298     """A batch processor for ICourse objects.
     314    """The Course Processor works exactly in the same way as the
     315    Certificate Processor. It uses the courses catalog instead of the
     316    certificates catalog.
    299317    """
    300318    grok.implements(IBatchProcessor)
     
    343361
    344362class CertificateCourseProcessor(FacultyProcessor):
    345     """A batch processor for ICertificateCourse objects.
     363    """The Certificate Course Processor needs more location fields.
     364    Certificate courses are stored inside the certificate container.
     365    Thus, `faculty_code`, `department_code` and the
     366    `certificate_code` are necessary to find the parent container.
     367    It furthermore needs the `course` and the `level` field to locate
     368    existing objects as they are part of the object id (code).
    346369    """
    347370    grok.implements(IBatchProcessor)
Note: See TracChangeset for help on using the changeset viewer.