Ignore:
Timestamp:
6 Aug 2011, 11:11:41 (13 years ago)
Author:
uli
Message:

Implement a new logging technique and use it.
Details are explained in waeup.sirp.utils.logger.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
2 edited

Legend:

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

    r6500 r6578  
    2727from hurry.query.interfaces import IQuery
    2828from zope.component import getUtility
    29 from waeup.sirp.interfaces import IWAeUPSIRPPluggable, ISiteLoggers
     29from waeup.sirp.interfaces import IWAeUPSIRPPluggable
    3030from waeup.sirp.applicants.interfaces import IApplicantsRoot
    3131from waeup.sirp.utils.helpers import get_current_principal
     32from waeup.sirp.utils.logger import Logger
    3233
    33 class ApplicantsRoot(grok.Container):
     34class ApplicantsRoot(grok.Container, Logger):
    3435    """The root of applicants-related components. It contains only
    3536    containers for applicants.
     
    3940    local_roles = ['waeup.ApplicationsOfficer']
    4041
    41     @property
    42     def logger(self):
    43         """Get a logger for applicants.
    44         """
    45         loggers = getUtility(ISiteLoggers).getLoggers()
    46         if 'waeup.sirp.%s.applicants' not in loggers.keys():
    47             loggers.register('waeup.sirp.%s.applicants')
    48         return loggers.getLogger('waeup.sirp.%s.applicants')
     42    logger_name = 'waeup.sirp.${sitename}.applicants'
     43    logger_filename = 'applicants.log'
    4944
    5045    def logger_info(self, target, ob_class, comment=None):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_root.py

    r6443 r6578  
    2828import unittest
    2929from StringIO import StringIO
    30 from zope.app.testing.functional import FunctionalTestCase
    31 from zope.component.hooks import setSite, clearSite
     30from zope.component.hooks import setSite
    3231from zope.interface.verify import verifyClass, verifyObject
    33 from zope.site import LocalSiteManager
    3432from waeup.sirp.app import University
    3533from waeup.sirp.applicants import (
     
    4038    ApplicantsRoot, ApplicantsPlugin,
    4139    )
    42 from waeup.sirp.testing import FunctionalLayer
     40from waeup.sirp.testing import (
     41    FunctionalLayer, FunctionalTestCase, get_all_loggers, remove_new_loggers,
     42    remove_logger)
    4343
    4444
     
    5454    def setUp(self):
    5555        super(ApplicantsRootTestCase, self).setUp()
    56 
     56        remove_logger('waeup.sirp.app.applicants')
     57        self.old_loggers = get_all_loggers()
    5758        # Setup a sample site for each test
     59
     60        # Prepopulate the ZODB...
    5861        app = University()
    59         self.dc_root = tempfile.mkdtemp()
    60         app['datacenter'].setStoragePath(self.dc_root)
    61 
    62         # Prepopulate the ZODB...
    6362        self.getRootFolder()['app'] = app
    6463        self.app = self.getRootFolder()['app']
    6564        setSite(self.app)
     65
     66        self.dc_root = tempfile.mkdtemp()
     67        app['datacenter'].setStoragePath(self.dc_root)
     68
    6669        return
    6770
    6871    def tearDown(self):
    6972        super(ApplicantsRootTestCase, self).tearDown()
     73        remove_new_loggers(self.old_loggers)
    7074        shutil.rmtree(self.dc_root)
    7175        return
Note: See TracChangeset for help on using the changeset viewer.