Ignore:
Timestamp:
17 Jun 2012, 07:32:08 (13 years ago)
Author:
Henrik Bettermann
Message:

Use different msave method in students and in university.

Simplify logging. We don't need the logger_info method.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
5 edited

Legend:

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

    r8736 r8737  
    6262from waeup.kofa.browser.resources import toggleall
    6363from waeup.kofa.hostels.hostel import NOT_OCCUPIED
    64 from waeup.kofa.utils.helpers import get_current_principal, to_timezone, msave
     64from waeup.kofa.utils.helpers import get_current_principal, to_timezone
     65
     66# Save function used for save methods in pages
     67def msave(view, **data):
     68    changed_fields = view.applyData(view.context, **data)
     69    # Turn list of lists into single list
     70    if changed_fields:
     71        changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
     72    # Inform catalog if certificate has changed
     73    # (applyData does this only for the context)
     74    if 'certificate' in changed_fields:
     75        notify(grok.ObjectModifiedEvent(view.context.student))
     76    fields_string = ' + '.join(changed_fields)
     77    view.flash(_('Form has been saved.'))
     78    if fields_string:
     79        view.context.writeLogMessage(view, 'saved: %s' % fields_string)
     80    return
    6581
    6682def emit_lock_message(view):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/container.py

    r8410 r8737  
    3939    _curr_stud_id = 10 ** 6
    4040
     41    logger_name = 'waeup.kofa.${sitename}.students'
     42    logger_filename = 'students.log'
     43
    4144    @property
    4245    def unique_student_id(self):
     
    7780        return
    7881
    79     logger_name = 'waeup.kofa.${sitename}.students'
    80     logger_filename = 'students.log'
    81 
    82     def logger_info(self, ob_class, target, comment=None):
    83         """Get the logger's info method.
    84         """
    85         self.logger.info('%s - %s - %s' % (
    86                 ob_class, target, comment))
    87         return
    88 
    8982StudentsContainer = attrs_to_fields(StudentsContainer)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r8736 r8737  
    6363    def writeLogMessage(self, view, message):
    6464        ob_class = view.__implemented__.__name__.replace('waeup.kofa.','')
    65         return self.__parent__.logger_info(ob_class,self.__name__,comment=None)
     65        self.__parent__.logger.info(
     66            '%s - %s - %s' % (ob_class, self.__name__, message))
     67        return
    6668
    6769    @property
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.py

    r8735 r8737  
    8686        return
    8787
     88    #def writeLogMessage(self, view, message):
     89    #    ob_class = view.__implemented__.__name__.replace('waeup.kofa.','')
     90    #    return self.__parent__.logger_info(ob_class,self.__name__,comment=None)
     91
    8892class CertificateFactory(grok.GlobalUtility):
    8993    """A factory for certificates.
     
    151155        studycourse.certificate = None
    152156        notify(grok.ObjectModifiedEvent(student))
    153         student.__parent__.logger_info(
    154             'ObjectRemovedEvent',student.__name__,'removed: certificate')
     157        student.__parent__.logger.info(
     158            'ObjectRemovedEvent - %s - removed: certificate' % student.__name__)
    155159    return
    156160
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py

    r8736 r8737  
    690690    if changed_fields:
    691691        changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
    692     # Inform catalog if certificate has changed
    693     # (applyData does this only for the context)
    694     if 'certificate' in changed_fields:
    695         notify(grok.ObjectModifiedEvent(view.context.student))
    696692    fields_string = ' + '.join(changed_fields)
    697693    view.flash(_('Form has been saved.'))
Note: See TracChangeset for help on using the changeset viewer.