Changeset 7656 for main/waeup.sirp


Ignore:
Timestamp:
16 Feb 2012, 08:35:53 (13 years ago)
Author:
Henrik Bettermann
Message:

Be more verbose in log messages when creating or updating students or study courses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py

    r7652 r7656  
    134134        parent = self.getParent(row, site)
    135135        parent.addStudent(obj)
    136         # In some tests we don't have a students container
    137         try:
    138             parent.logger.info('%s - Student record imported' % (
    139                 obj.student_id))
    140             history = IObjectHistory(obj)
    141             history.addMessage('Student record imported')
    142         except (TypeError, AttributeError):
    143             pass
     136        # We don't need to log this because is already done by the workflow
     137        # transition even handler.
     138        history = IObjectHistory(obj)
     139        history.addMessage('Student record imported')
    144140        return
    145141
     
    148144        if student is not None:
    149145            parent = self.getParent(row, site)
     146            parent.logger.info('%s - Student removed' % student.student_id)
    150147            del parent[student.student_id]
    151148        pass
     
    157154        if row.has_key('student_id') and row['student_id'] is None:
    158155            row.pop('student_id')
     156        items_changed = ''
    159157        for key, value in row.items():
    160158            # Set student password and all fields declared in interface.
     
    168166            elif hasattr(obj, key):
    169167                setattr(obj, key, value)
     168            items_changed += '%s=%s, ' % (key,value)
     169        parent = self.getParent(row, site)
     170        if hasattr(obj,'student_id'):
     171            # Update mode: the student exists and we can get the student_id
     172            parent.logger.info(
     173                '%s - Student record updated: %s'
     174                % (obj.student_id, items_changed))
     175        else:
     176            # Create mode: the student does not yet exist
     177            parent.logger.info('Student data imported: %s' % items_changed)
    170178        return
    171179
     
    281289        """Update obj to the values given in row.
    282290        """
     291        items_changed = ''
    283292        for key, value in row.items():
    284293            # Skip fields not declared in interface.
    285294            if hasattr(obj, key):
    286295                setattr(obj, key, value)
     296                if key == 'certificate':
     297                    value = value.code
     298            items_changed += '%s=%s, ' % (key,value)
     299        parent = self.getParent(row, site)
     300        parent.__parent__.logger.info(
     301            '%s - Study course updated: %s'
     302            % (parent.student_id, items_changed))
    287303        # Update the students_catalog
    288304        notify(grok.ObjectModifiedEvent(obj.__parent__))
Note: See TracChangeset for help on using the changeset viewer.