Ignore:
Timestamp:
21 Nov 2012, 22:37:03 (12 years ago)
Author:
Henrik Bettermann
Message:

Rework logging of batch processing. Remove redundant text but add name of import file.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

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

    r9701 r9706  
    185185        return None
    186186
    187     def updateEntry(self, obj, row, site):
     187    def updateEntry(self, obj, row, site, filename):
    188188        """Update obj to the values given in row.
    189189        """
     
    230230        # apply other values...
    231231        items_changed += super(StudentProcessor, self).updateEntry(
    232             obj, row, site)
     232            obj, row, site, filename)
    233233
    234234        # Log actions...
     
    238238            # Create mode: the record contains the student_id
    239239            parent.logger.info(
    240                 '%s - Student record updated: %s'
    241                 % (obj.student_id, items_changed))
     240                '%s - %s - %s - updated: %s'
     241                % (self.name, filename, obj.student_id, items_changed))
    242242        else:
    243243            # Create mode: the student does not yet exist
    244             parent.logger.info('Student data imported: %s' % items_changed)
     244            # XXX: It seems that this never happens because student_id
     245            # is always set.
     246            parent.logger.info(
     247                '%s - %s - %s - imported: %s'
     248                % (self.name, filename, obj.student_id, items_changed))
    245249        return items_changed
    246250
     
    418422        return student.get('studycourse')
    419423
    420     def updateEntry(self, obj, row, site):
     424    def updateEntry(self, obj, row, site, filename):
    421425        """Update obj to the values given in row.
    422426        """
    423427        items_changed = super(StudentStudyCourseProcessor, self).updateEntry(
    424             obj, row, site)
     428            obj, row, site, filename)
    425429        parent = self.getParent(row, site)
    426430        parent.__parent__.logger.info(
    427             '%s - Study course updated: %s'
    428             % (parent.student_id, items_changed))
     431            '%s - %s - %s - updated: %s'
     432            % (self.name, filename, parent.student_id, items_changed))
    429433        # Update the students_catalog
    430434        notify(grok.ObjectModifiedEvent(obj.__parent__))
     
    503507        return
    504508
    505     def updateEntry(self, obj, row, site):
     509    def updateEntry(self, obj, row, site, filename):
    506510        """Update obj to the values given in row.
    507511        """
    508512        items_changed = super(StudentStudyLevelProcessor, self).updateEntry(
    509             obj, row, site)
     513            obj, row, site, filename)
    510514        student = self.getParent(row, site).__parent__
    511515        student.__parent__.logger.info(
    512             '%s - Study level updated: %s'
    513             % (student.student_id, items_changed))
     516            '%s - %s - %s - updated: %s'
     517            % (self.name, filename, student.student_id, items_changed))
    514518        return
    515519
     
    574578        return level.get(row['code'])
    575579
    576     def updateEntry(self, obj, row, site):
     580    def updateEntry(self, obj, row, site, filename):
    577581        """Update obj to the values given in row.
    578582        """
    579583        items_changed = super(CourseTicketProcessor, self).updateEntry(
    580             obj, row, site)
     584            obj, row, site, filename)
    581585        parent = self.getParent(row, site)
    582586        student = self.getParent(row, site).__parent__.__parent__
    583587        student.__parent__.logger.info(
    584             '%s - Course ticket in %s updated: %s'
    585             % (student.student_id, parent.level, items_changed))
     588            '%s - %s - %s - %s - updated: %s'
     589            % (self.name, filename, student.student_id, parent.level, items_changed))
    586590        return
    587591
     
    690694        return entry
    691695
    692     def updateEntry(self, obj, row, site):
     696    def updateEntry(self, obj, row, site, filename):
    693697        """Update obj to the values given in row.
    694698        """
    695699        items_changed = super(StudentOnlinePaymentProcessor, self).updateEntry(
    696             obj, row, site)
     700            obj, row, site, filename)
    697701        student = self.getParent(row, site).__parent__
    698702        student.__parent__.logger.info(
    699             '%s - Payment ticket updated: %s'
    700             % (student.student_id, items_changed))
     703            '%s - %s - %s - updated: %s'
     704            % (self.name, filename, student.student_id, items_changed))
    701705        return
    702706
     
    798802        return None
    799803
    800     def updateEntry(self, obj, row, site):
     804    def updateEntry(self, obj, row, site, filename):
    801805        """Update obj to the values given in row.
    802806        """
     
    804808        vals_to_set = dict((key, val) for key, val in row.items()
    805809                           if key not in ('current_session','current_level'))
    806         super(StudentVerdictProcessor, self).updateEntry(obj, vals_to_set, site)
     810        super(StudentVerdictProcessor, self).updateEntry(
     811            obj, vals_to_set, site, filename)
    807812        parent = self.getParent(row, site)
    808813        # Set current_vedict in corresponding studylevel
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9467 r9706  
    666666        # Logging message from updateEntry,
    667667        self.assertTrue(
    668             'INFO - system - K1000000 - Study level '
    669             'updated: level=100, level_verdict=C, level_session=2009'
     668            'INFO - system - StudentStudyLevel Processor - '
     669            'sample_studylevel_data - K1000000 - updated: '
     670            'level=100, level_verdict=C, level_session=2009'
    670671            in logcontent)
    671672
     
    788789        self.assertEqual(courseticket.semester, 1)
    789790        shutil.rmtree(os.path.dirname(fin_file))
    790 
    791791        logcontent = open(self.logfile).read()
    792792        # Logging message from updateEntry,
    793793        self.assertTrue(
    794             'INFO - system - K1000000 - Course ticket in 100 updated: code=COURSE1, '
     794            'INFO - system - CourseTicket Processor - '
     795            'sample_courseticket_data - K1000000 - 100 - '
     796            'updated: code=COURSE1, '
    795797            'mandatory=False, score=3'
    796798            in logcontent)
     
    968970        # Logging message from updateEntry
    969971        self.assertTrue(
    970             'INFO - system - K1000001 - Payment ticket updated: '
     972            'INFO - system - Student Payment Processor - '
     973            'sample_payment_data - K1000001 - updated: '
    971974            'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, '
    972975            'p_category=schoolfee, amount_auth=19500.0, p_current=True, '
     
    975978            in logcontent)
    976979        self.assertTrue(
    977             'INFO - system - K1000001 - Payment ticket updated: '
     980            'INFO - system - Student Payment Processor - '
     981            'sample_payment_data - K1000001 - updated: '
    978982            'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, '
    979983            'p_category=schoolfee, amount_auth=19500.6, p_current=True, '
     
    10891093        logcontent = open(self.logfile).read()
    10901094        self.assertMatches(
    1091             '... INFO - system - X666666 - Study course updated: current_verdict=0...',
     1095            '... INFO - system - Verdict Processor (special processor, '
     1096            'update only) - sample_verdict_data - X666666 - '
     1097            'updated: current_verdict=0...',
    10921098            logcontent)
    10931099        self.assertMatches(
Note: See TracChangeset for help on using the changeset viewer.