Changeset 4883


Ignore:
Timestamp:
23 Jan 2010, 17:58:36 (15 years ago)
Author:
uli
Message:
  • Add event when datacenter storage moves.
  • Fix logger name to work also with plain unittests.
  • Handle logger when storage path of datacenter changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/trunk/src/waeup/datacenter.py

    r4873 r4883  
    1010from datetime import datetime
    1111from zope.component import getMultiAdapter
     12from zope.component.interfaces import ObjectEvent
    1213from waeup.csvfile import getCSVFile
    1314from waeup.interfaces import (IDataCenter, IWAeUPCSVImporter,
    14                               ICSVDataReceivers, IDataCenterFile)
     15                              ICSVDataReceivers, IDataCenterFile,
     16                              IDataCenterStorageMovedEvent)
    1517from waeup.utils.helpers import copyFileSystemTree
    1618
     
    2729        # We need a different logger for every site...
    2830        site = grok.getSite()
    29         sitename = site.__name__
     31        sitename = getattr(site, '__name__', 'app')
    3032        loggername = 'waeup.sirp.%s.datacenter' % sitename
    3133        logger = logging.getLogger(loggername)
     
    5254        # application log.
    5355        logger.propagate = False
     56        logger.setLevel(logging.DEBUG)
    5457        logger.addHandler(handler)
    5558        return logger
     
    141144                                            overwrite=overwrite)
    142145        self.storage = path
     146        # Adjust logger...
     147        logger = self.logger
     148        handlers = logger.handlers
     149        for handler in handlers:
     150            logger.removeHandler(handler)
     151        self._setupLogger(logger)
     152        grok.notify(DataCenterStorageMovedEvent(self))
    143153        return not_copied
    144154
     
    328338            importer.receiverid = receiverid
    329339            self.importers.append(importer)
     340
     341class DataCenterStorageMovedEvent(ObjectEvent):
     342    """An event fired, when datacenter storage moves.
     343    """
     344    grok.implements(IDataCenterStorageMovedEvent)
Note: See TracChangeset for help on using the changeset viewer.