[Checkins] SVN: Zope/branches/2.11/ Zope2 startup: Zope will now send a ProcessStarting event when it

Andreas Jung andreas at andreas-jung.com
Wed Dec 26 05:12:04 EST 2007


Log message for revision 82447:
  Zope2 startup: Zope will now send a ProcessStarting event when it 
  is ready to serve requests. You can subscribe to this event e.g.
  for starting application-level threads. 
  

Changed:
  U   Zope/branches/2.11/doc/CHANGES.txt
  U   Zope/branches/2.11/lib/python/Zope2/Startup/__init__.py

-=-
Modified: Zope/branches/2.11/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.11/doc/CHANGES.txt	2007-12-26 09:51:10 UTC (rev 82446)
+++ Zope/branches/2.11/doc/CHANGES.txt	2007-12-26 10:12:03 UTC (rev 82447)
@@ -54,6 +54,10 @@
 
     Features added
 
+      - Zope2 startup: Zope will now send a ProcessStarting event when it 
+        is ready to serve requests. You can subscribe to this event e.g.
+        for starting application-level threads. 
+
       - Testing.ZopeTestCase: Introduced a "ZopeLite" test layer, making it
         possible to mix ZTC and non-ZTC tests much more freely.
 

Modified: Zope/branches/2.11/lib/python/Zope2/Startup/__init__.py
===================================================================
--- Zope/branches/2.11/lib/python/Zope2/Startup/__init__.py	2007-12-26 09:51:10 UTC (rev 82446)
+++ Zope/branches/2.11/lib/python/Zope2/Startup/__init__.py	2007-12-26 10:12:03 UTC (rev 82447)
@@ -30,6 +30,9 @@
 import ZConfig
 from ZConfig.components.logger import loghandler
 
+from zope.event import notify
+from zope.app import appsetup
+
 logger = logging.getLogger("Zope")
 started = False
 
@@ -85,6 +88,10 @@
     def setConfiguration(self, cfg):
         self.cfg = cfg
 
+
+    def sendEvents(self):
+        notify(appsetup.interfaces.ProcessStarting())
+
     def prepare(self):
         self.setupInitialLogging()
         self.setupLocale()
@@ -108,8 +115,10 @@
         # emit a "ready" message in order to prevent the kinds of emails
         # to the Zope maillist in which people claim that Zope has "frozen"
         # after it has emitted ZServer messages.
+        
         logger.info('Ready to handle requests')
         self.setupFinalLogging()
+        self.sendEvents()
 
     def run(self):
         # the mainloop.



More information about the Checkins mailing list