[Checkins] SVN: zope.app.appsetup/trunk/ Set up error log in appsetup instead of zope.error to remove dependency

Martijn Faassen faassen at infrae.com
Fri Jan 30 07:01:44 EST 2009


Log message for revision 95550:
  Set up error log in appsetup instead of zope.error to remove dependency
  from zope.error on zope.app.appsetup.
  

Changed:
  U   zope.app.appsetup/trunk/CHANGES.txt
  U   zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml
  A   zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py
  U   zope.app.appsetup/trunk/src/zope/app/appsetup/testdata/site.zcml
  U   zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py

-=-
Modified: zope.app.appsetup/trunk/CHANGES.txt
===================================================================
--- zope.app.appsetup/trunk/CHANGES.txt	2009-01-30 12:01:01 UTC (rev 95549)
+++ zope.app.appsetup/trunk/CHANGES.txt	2009-01-30 12:01:43 UTC (rev 95550)
@@ -7,6 +7,11 @@
 
 - Use zope.container instead of zope.app.container
 
+- Move error log bootstrapping logic from ``zope.error`` into this
+  package.  This removes a dependency from zope.error to this
+  package. Also added a test for bootstrapping the error log here,
+  which was missing in ``zope.error``.
+
 Version 3.8.0 (2008-08-25)
 --------------------------
 

Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml	2009-01-30 12:01:01 UTC (rev 95549)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/configure.zcml	2009-01-30 12:01:43 UTC (rev 95550)
@@ -2,12 +2,17 @@
 
   <subscriber
       handler=".bootstrap.bootStrapSubscriber"
-      for="zope.app.appsetup.IDatabaseOpenedEvent"
+      for="zope.app.appsetup.interfaces.IDatabaseOpenedEvent"
       />
 
   <subscriber
       handler=".bootstrap.checkSecurityPolicy"
-      for="zope.app.appsetup.IDatabaseOpenedEvent"
+      for="zope.app.appsetup.interfaces.IDatabaseOpenedEvent"
+      />  
+
+  <subscriber
+      handler=".errorlog.bootStrapSubscriber"
+      for="zope.app.appsetup.interfaces.IDatabaseOpenedWithRootEvent"
       />
 
 </configure>

Copied: zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py (from rev 95539, zope.error/trunk/src/zope/error/bootstrap.py)
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py	                        (rev 0)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py	2009-01-30 12:01:43 UTC (rev 95550)
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# Copyright (c) 2002, 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap code for error reporting utility.
+
+$Id: bootstrap.py 70794 2006-10-19 04:29:42Z baijum $
+"""
+
+import transaction
+
+from zope.error.error import RootErrorReportingUtility
+from zope.error.interfaces import IErrorReportingUtility
+
+from zope.app.appsetup.bootstrap import ensureUtility, getInformationFromEvent
+
+def bootStrapSubscriber(event):
+    """Subscriber to the IDataBaseOpenedEvent
+
+    Create utility at that time if not yet present
+    """
+
+    db, connection, root, root_folder = getInformationFromEvent(event)
+
+    ensureUtility(root_folder, IErrorReportingUtility, '',
+                  RootErrorReportingUtility, copy_to_zlog=False, asObject=True)
+
+    transaction.commit()
+    connection.close()


Property changes on: zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py
___________________________________________________________________
Added: svn:mergeinfo
   + 
Added: svn:eol-style
   + native

Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/testdata/site.zcml
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/testdata/site.zcml	2009-01-30 12:01:01 UTC (rev 95549)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/testdata/site.zcml	2009-01-30 12:01:43 UTC (rev 95550)
@@ -1,5 +1,12 @@
 <configure>
   <include package="zope.component" file="meta.zcml" />
   <include package="zope.component" />
+
+  <include package="zope.security" file="meta.zcml" />
+  <include package="zope.app.component" file="meta.zcml" />
+  <include package="zope.app.component" /> 
+  <include package="zope.app.security" />
+  <include package="zope.traversing" />
+
   <include package="zope.app.appsetup" />
 </configure>

Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py	2009-01-30 12:01:01 UTC (rev 95549)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py	2009-01-30 12:01:43 UTC (rev 95550)
@@ -40,6 +40,8 @@
 from zope.app.appsetup.bootstrap import bootStrapSubscriber
 from zope.app.appsetup.bootstrap import getInformationFromEvent, \
      ensureObject, ensureUtility
+from zope.app.appsetup.interfaces import DatabaseOpened
+from zope.app.appsetup.errorlog import bootStrapSubscriber as errorlogBootStrapSubscriber
 
 from zope.app.testing import placelesssetup
 
@@ -160,7 +162,27 @@
 
         cx.close()
 
+    def test_errorReportingSetup(self):
+        """Error reporting is set up by an event handler in this package.
 
+        We test whether the event handler works.
+        """
+        self.createRFAndSM()
+
+        event = DatabaseOpened(self.db)        
+        # this will open and close the database by itself
+        errorlogBootStrapSubscriber(event)
+
+        # this will re-open the database
+        db, connection, root, root_folder = getInformationFromEvent(event)
+
+        got_utility = zope.component.getUtility(IErrorReportingUtility,
+                                                context=root_folder)
+        self.failUnless(IErrorReportingUtility.providedBy(got_utility))
+        # we need to close again in the end
+        connection.close()
+
+        
 class TestConfigurationSchema(unittest.TestCase):
 
     def setUp(self):



More information about the Checkins mailing list