[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/publication/ Removed
code to implicitly create a root error logging service when an
Jim Fulton
jim at zope.com
Sat Jul 10 09:03:08 EDT 2004
Log message for revision 26393:
Removed code to implicitly create a root error logging service when an
error occurs and there is no local error logging service.
-=-
Deleted: Zope3/trunk/src/zope/app/publication/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/ftests.py 2004-07-10 12:57:18 UTC (rev 26392)
+++ Zope3/trunk/src/zope/app/publication/ftests.py 2004-07-10 13:03:08 UTC (rev 26393)
@@ -1,72 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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.
-#
-##############################################################################
-"""Functional tests for Zope Publication
-
-$Id: ftests.py 25177 2004-06-02 13:17:31Z jim $
-"""
-import unittest
-from zope.app import zapi
-from zope.app.tests.functional import BrowserTestCase
-
-class TestErrorReportingService(BrowserTestCase):
-
- def testAddMissingErrorReportingService(self):
- # Unregister and remove the existing error reporting service
- self.publish(
- '/++etc++site/default/RegistrationManager/ServiceRegistration/',
- basic='mgr:mgrpw',
- form={'field.permission': '',
- 'field.status': 'Unregistered',
- 'UPDATE_SUBMIT': 'Change'})
- self.publish(
- '/++etc++site/default/RegistrationManager/',
- basic='mgr:mgrpw',
- form={'keys': ['ServiceRegistration'],
- 'remove_submit': 'Remove'})
- self.publish(
- '/++etc++site/default/@@contents.html',
- basic='mgr:mgrpw',
- form={'ids': ['ErrorLogging'],
- 'container_delete_button': 'Delete'})
-
- root = self.getRootFolder()
- default = zapi.traverse(root, '++etc++site/default')
- self.assert_('ErrorLogging' not in default.keys())
-
- # Force a NotFoundError, so that the error reporting service is
- # created again.
- response = self.publish('/foobar', basic='mgr:mgrpw',
- handle_errors=True)
- self.assertEqual(response.getStatus(), 404)
- body = response.getBody()
- self.assert_(
- 'The page that you are trying to access is not available' in body)
-
- # Now make sure that we have a new error reporting service with the
- # right entry.
- root = self.getRootFolder()
- default = zapi.traverse(root, '++etc++site/default')
- self.assert_('ErrorLogging' in default.keys())
- entry = default['ErrorLogging'].getLogEntries()[0]
- self.assertEqual(entry['type'], 'NotFound')
- self.assert_('foobar' in entry['tb_text'])
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(TestErrorReportingService),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py 2004-07-10 12:57:18 UTC (rev 26392)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py 2004-07-10 13:03:08 UTC (rev 26393)
@@ -204,39 +204,8 @@
self.beginErrorHandlingTransaction(request, object,
'error reporting service')
try:
- try:
- errService = zapi.getService(zapi.servicenames.ErrorLogging)
- # We only want to get the global error reporting service, if
- # we are not in a site. If we are, we want a local error
- # reporting service.
- # The global error reporting service does not have a
- # __parent__
- if getSite() is not None and \
- getattr(errService, '__parent__', None) is None:
- raise ComponentLookupError
+ errService = zapi.getService(zapi.servicenames.ErrorLogging)
- except ComponentLookupError:
- # There is no error reporting service. This is extremely
- # unlikely, since such a service is created when the ZODB is
- # first generated. So someone must have deliberately deleted
- # it.
- #
- # We need to go to the root folder and add a root error
- # reporting service there. And just in case the object passed
- # is not a contained object or a method, we use the local site
- # to find the root folder.
-
- # Import here to avoid circular imports. This is okay, since
- # this is a very special case.
- # This is the same code used in the bootstrap mechanism.
- from zope.app.appsetup.bootstrap import addConfigureService
- addConfigureService(zapi.getRoot(getSite()),
- zapi.servicenames.ErrorLogging,
- RootErrorReportingService,
- copy_to_zlog=True)
-
- errService = zapi.getService(zapi.servicenames.ErrorLogging)
-
# It is important that an error in errService.raising
# does not propagate outside of here. Otherwise, nothing
# meaningful will be returned to the user.
More information about the Zope3-Checkins
mailing list