Changeset 7652 for main/waeup.sirp


Ignore:
Timestamp:
15 Feb 2012, 10:51:53 (13 years ago)
Author:
Henrik Bettermann
Message:

Do not retrieve current principal in derived logging components. This is now done by the parent Logger class.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py

    r7438 r7652  
    3333    IExtFileStore, IPDF, IUserAccount)
    3434from waeup.sirp.students.vocabularies import RegNumNotInSource
    35 from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal
     35from waeup.sirp.utils.helpers import attrs_to_fields
    3636from waeup.sirp.applicants.interfaces import IApplicant, IApplicantEdit
    3737
     
    314314    comment = 'Applicant record removed'
    315315    target = applicant.applicant_id
    316     # In some tests we don't have a principal
    317316    try:
    318         user = get_current_principal().id
    319     except (TypeError, AttributeError):
    320         return
    321     try:
    322         grok.getSite()['applicants'].logger.info('%s - %s - %s' % (
    323             user, target, comment))
     317        grok.getSite()['applicants'].logger.info('%s - %s' % (
     318            target, comment))
    324319    except KeyError:
    325320        # If we delete an entire university instance there won't be
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py

    r7375 r7652  
    2525from waeup.sirp.interfaces import ISIRPPluggable
    2626from waeup.sirp.applicants.interfaces import IApplicantsRoot
    27 from waeup.sirp.utils.helpers import get_current_principal
    2827from waeup.sirp.utils.logger import Logger
    2928
     
    4241        """Get the logger's info method.
    4342        """
    44         user = get_current_principal()
    45         user = getattr(user, 'id', 'system')
    46         self.logger.info('%s - %s - %s - %s' % (
    47                 user, target, ob_class, comment))
     43        self.logger.info('%s - %s - %s' % (
     44                target, ob_class, comment))
    4845        return
    4946
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/workflow.py

    r7370 r7652  
    2424from waeup.sirp.interfaces import IObjectHistory, ISIRPWorkflowInfo
    2525from waeup.sirp.workflow import SIRPWorkflow, SIRPWorkflowInfo
    26 from waeup.sirp.utils.helpers import get_current_principal
    2726
    2827INITIALIZED = 'initialized'
     
    157156    # In some tests we don't have a an applicants root or a user
    158157    try:
    159         user = get_current_principal()
    160158        applicants_root = grok.getSite()['applicants']
    161         applicants_root.logger.info('%s - %s - %s' % (user.id,obj.applicant_id,msg))
     159        applicants_root.logger.info('%s - %s' % (obj.applicant_id,msg))
    162160    except (TypeError, AttributeError):
    163161        pass
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/container.py

    r7257 r7652  
    2121import grok
    2222from waeup.sirp.hostels.interfaces import IHostelsContainer, IHostel
    23 from waeup.sirp.utils.helpers import get_current_principal
    2423from waeup.sirp.utils.logger import Logger
    2524
     
    5554        """Get the logger's info method.
    5655        """
    57         user = get_current_principal()
    58         user = user.id
    59         self.logger.info('%s - %s - %s - %s' % (
    60                 user, ob_class, target, comment))
     56        self.logger.info('%s - %s - %s' % (
     57                ob_class, target, comment))
    6158        return
    6259
  • main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py

    r7649 r7652  
    4242from waeup.sirp.students.workflow import  IMPORTABLE_STATES
    4343from waeup.sirp.utils.batching import BatchProcessor
    44 from waeup.sirp.utils.helpers import get_current_principal
    4544
    4645class StudentProcessor(BatchProcessor):
     
    135134        parent = self.getParent(row, site)
    136135        parent.addStudent(obj)
    137         # In some tests we don't have a students container or a user
     136        # In some tests we don't have a students container
    138137        try:
    139             user = get_current_principal()
    140             parent.logger.info('%s - %s - Student record imported' % (
    141                 user.id,obj.student_id))
     138            parent.logger.info('%s - Student record imported' % (
     139                obj.student_id))
    142140            history = IObjectHistory(obj)
    143141            history.addMessage('Student record imported')
  • main/waeup.sirp/trunk/src/waeup/sirp/students/container.py

    r7256 r7652  
    2222from waeup.sirp.students.interfaces import (
    2323    IStudentsContainer, IStudent)
    24 from waeup.sirp.utils.helpers import get_current_principal
    2524from waeup.sirp.utils.logger import Logger
    2625
     
    5352        """Get the logger's info method.
    5453        """
    55         user = get_current_principal()
    56         if user is None:
    57             # In tests we do not necessarily have a logged on principal
    58             return
    59         user = user.id
    60         self.logger.info('%s - %s - %s - %s' % (
    61                 user, ob_class, target, comment))
     54        self.logger.info('%s - %s - %s' % (
     55                ob_class, target, comment))
    6256        return
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r7641 r7652  
    3535from waeup.sirp.students.payments import StudentPaymentsContainer
    3636from waeup.sirp.students.accommodation import StudentAccommodation
    37 from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal
     37from waeup.sirp.utils.helpers import attrs_to_fields
    3838from waeup.sirp.students.utils import generate_student_id
    3939
     
    174174    comment = 'Student record removed'
    175175    target = student.student_id
    176     # In some tests we don't have a principal
    177176    try:
    178         user = get_current_principal().id
    179     except (TypeError, AttributeError):
    180         return
    181     try:
    182         grok.getSite()['students'].logger.info('%s - %s - %s' % (
    183             user, target, comment))
     177        grok.getSite()['students'].logger.info('%s - %s' % (
     178            target, comment))
    184179    except KeyError:
    185180        # If we delete an entire university instance there won't be
  • main/waeup.sirp/trunk/src/waeup/sirp/students/workflow.py

    r7615 r7652  
    1010    REGISTERED, VALIDATED)
    1111from waeup.sirp.workflow import SIRPWorkflow, SIRPWorkflowInfo
    12 from waeup.sirp.utils.helpers import get_current_principal
    1312from waeup.sirp.students.interfaces import IStudent, IStudentsUtils
    1413
     
    197196    if event.transition.transition_id == 'pay_school_fee':
    198197        getUtility(IStudentsUtils).setReturningData(obj)
    199     # In some tests we don't have a students container or a user
     198    # In some tests we don't have a students container
    200199    try:
    201         user = get_current_principal()
    202200        students_container = grok.getSite()['students']
    203         students_container.logger.info('%s - %s - %s' % (user.id,obj.student_id,msg))
     201        students_container.logger.info('%s - %s' % (obj.student_id,msg))
    204202    except (TypeError, AttributeError):
    205203        pass
Note: See TracChangeset for help on using the changeset viewer.