Changeset 6754 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 14 Sep 2011, 00:48:11 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/batchprocessing.txt
r6734 r6754 557 557 >>> 'datacenter.log' in browser.contents 558 558 True 559 >>> browser.getControl('Show', index= 1).click()559 >>> browser.getControl('Show', index=0).click() 560 560 >>> '<input type="submit" name="back" value="Back" />' in browser.contents 561 561 True -
main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py
r6569 r6754 484 484 paths. 485 485 """ 486 487 class ILoggerCollector(Interface): 488 489 def getLoggers(site): 490 """Return all loggers registered for `site`. 491 """ 492 493 def registerLogger(site, logging_component): 494 """Register a logging component residing in `site`. 495 """ 496 497 def unregisterLogger(site, logging_component): 498 """Unregister a logger. 499 """ -
main/waeup.sirp/trunk/src/waeup/sirp/testing.py
r6747 r6754 284 284 doctest.REPORT_NDIFF + doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE) 285 285 286 def clear_logger_collector(): 287 from zope.component import queryUtility, getGlobalSiteManager 288 from waeup.sirp.interfaces import ILoggerCollector 289 collector = queryUtility(ILoggerCollector) 290 if collector is None: 291 return 292 keys = collector.keys() 293 for key in keys: 294 del collector[key] 295 return 296 286 297 class FunctionalTestCase(FunctionalTestCase): 287 298 """A test case that supports checking output diffs in doctest style. … … 296 307 super(FunctionalTestCase, self).tearDown() 297 308 remove_new_loggers(self.functional_old_loggers) 309 clear_logger_collector() 298 310 return 299 311 -
main/waeup.sirp/trunk/src/waeup/sirp/utils/logger.py
r6745 r6754 84 84 from zope.component import queryUtility 85 85 from zope.interface import Interface, Attribute, implements 86 from waeup.sirp.interfaces import IDataCenter, IDataCenterStorageMovedEvent 86 from waeup.sirp.interfaces import ( 87 IDataCenter, IDataCenterStorageMovedEvent, ILoggerCollector) 87 88 88 89 #: Default logfile size (5 KB) … … 300 301 301 302 302 class ILoggerCollector(Interface):303 304 def getLoggers(site):305 """Return all loggers registered for `site`.306 """307 308 def registerLogger(site, logging_component):309 """Register a logging component residing in `site`.310 """311 312 def unregisterLogger(site, logging_component):313 """Unregister a logger.314 """315 316 303 class LoggerCollector(dict, grok.GlobalUtility): 317 304 """A global utility providing `ILoggerCollector`. … … 380 367 logger.logger_logfile_changed() 381 368 return 369 370 from waeup.sirp.interfaces import IUniversity 371 @grok.subscribe(IUniversity, grok.IObjectRemovedEvent) 372 def handle_site_removal(obj, event): 373 collector = queryUtility(ILoggerCollector) 374 name = getattr(obj, '__name__', None) 375 if name is None: 376 return 377 if name not in collector.keys(): 378 return 379 del collector[name] 380 return -
main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_logger.py
r6748 r6754 8 8 from zope.interface.verify import verifyClass, verifyObject 9 9 from waeup.sirp.app import University 10 from waeup.sirp.testing import ( 11 FunctionalLayer, FunctionalTestCase, get_all_loggers, 12 remove_new_loggers, remove_logger) 10 from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase 13 11 14 12 from waeup.sirp.utils.logger import ( … … 259 257 def setUp(self): 260 258 super(LoggerCollectorTests, self).setUp() 261 self.old_loggers = get_all_loggers()262 259 # Setup a sample site for each test 263 260 app = University() … … 281 278 def tearDown(self): 282 279 super(LoggerCollectorTests, self).tearDown() 283 remove_new_loggers(self.old_loggers)284 280 shutil.rmtree(self.workdir) 285 281 shutil.rmtree(self.dc_root) … … 357 353 def setUp(self): 358 354 super(LogfileChangeTests, self).setUp() 359 remove_logger('waeup.sirp.app') # In case it lingers around360 self.old_loggers = get_all_loggers()361 355 # Setup a sample site for each test 362 356 app = University() … … 373 367 self.component = self.app['mycomponent'] 374 368 setSite(self.app) 375 376 369 self.component = LoggingComponent() 377 370 return … … 379 372 def tearDown(self): 380 373 super(LogfileChangeTests, self).tearDown() 381 remove_new_loggers(self.old_loggers)382 374 shutil.rmtree(self.workdir) 383 375 shutil.rmtree(self.dc_root) … … 397 389 self.assertTrue(filename2.startswith(self.dc_root_new)) 398 390 return 391 392 def test_storage_deletion(self): 393 # When a site is deleted, the loggers should go away as well 394 self.dc_root_new = tempfile.mkdtemp() 395 logger1 = self.component.logger.handlers # create entry in collector 396 collector = queryUtility(ILoggerCollector) 397 loggers1 = collector.keys() 398 root = self.app.__parent__ 399 del root['app'] 400 loggers2 = collector.keys() 401 self.assertEqual(loggers1, ['app']) 402 self.assertEqual(loggers2, []) 403 return
Note: See TracChangeset for help on using the changeset viewer.