Changeset 4884


Ignore:
Timestamp:
23 Jan 2010, 18:01:03 (15 years ago)
Author:
uli
Message:

React via eventhandler when datacenter storage moves. We have to
reopen the application.log in that case.

File:
1 edited

Legend:

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

    r4874 r4884  
    66from zope.component import createObject
    77
    8 from waeup.interfaces import IUniversity, ICSVDataReceivers
     8from waeup.interfaces import (IUniversity, ICSVDataReceivers, IDataCenter,
     9                              IDataCenterStorageMovedEvent)
    910from waeup.authentication import setup_authentication
    1011from waeup.datacenter import DataCenter
     
    6566        logger.addHandler(handler)
    6667        return logger
     68
     69@grok.subscribe(IDataCenter, IDataCenterStorageMovedEvent)
     70def handle_storage_move(obj, event):
     71    """Event handler, in case datacenter storage moves.
     72
     73    We initialize the application log again, then.
     74    """
     75    app = grok.getSite()
     76    if app is None:
     77        return
     78    if obj is not app['datacenter']:
     79        return
     80    logger = app.logger
     81    logger.warn('Log Dir moved. Closing.')
     82    handlers = logger.handlers
     83    for handler in handlers:
     84        logger.removeHandler(handler)
     85    app._setupLogger(logger)
     86    logger.warn('Log file moved. Opening.')
Note: See TracChangeset for help on using the changeset viewer.