[Checkins] SVN: zope.errorview/trunk/src/zope/errorview/ Send an event when rendering an exception view.
Jan-Jaap Driessen
jdriessen at thehealthagency.com
Wed Jan 19 09:43:10 EST 2011
Log message for revision 119708:
Send an event when rendering an exception view.
Changed:
U zope.errorview/trunk/src/zope/errorview/http.py
A zope.errorview/trunk/src/zope/errorview/interfaces.py
A zope.errorview/trunk/src/zope/errorview/tests/test_event.py
-=-
Modified: zope.errorview/trunk/src/zope/errorview/http.py
===================================================================
--- zope.errorview/trunk/src/zope/errorview/http.py 2011-01-19 14:32:20 UTC (rev 119707)
+++ zope.errorview/trunk/src/zope/errorview/http.py 2011-01-19 14:43:10 UTC (rev 119708)
@@ -15,6 +15,8 @@
from zope.browser.interfaces import ISystemErrorView
from zope.interface import implements
from zope.publisher.interfaces.http import IHTTPException
+from zope.event import notify
+from zope.errorview.interfaces import HandleExceptionEvent
class SystemErrorViewMixin(object):
@@ -40,6 +42,7 @@
return u''
def __call__(self):
+ notify(HandleExceptionEvent(self.request))
self.update()
return self.render()
Added: zope.errorview/trunk/src/zope/errorview/interfaces.py
===================================================================
--- zope.errorview/trunk/src/zope/errorview/interfaces.py (rev 0)
+++ zope.errorview/trunk/src/zope/errorview/interfaces.py 2011-01-19 14:43:10 UTC (rev 119708)
@@ -0,0 +1,12 @@
+from zope.interface import Interface, implements, Attribute
+
+class IHandleExceptionEvent(Interface):
+ """Event fired when handling an exception."""
+
+ request = Attribute('The current request')
+
+class HandleExceptionEvent(object):
+ implements(IHandleExceptionEvent)
+
+ def __init__(self, request):
+ self.request = request
Added: zope.errorview/trunk/src/zope/errorview/tests/test_event.py
===================================================================
--- zope.errorview/trunk/src/zope/errorview/tests/test_event.py (rev 0)
+++ zope.errorview/trunk/src/zope/errorview/tests/test_event.py 2011-01-19 14:43:10 UTC (rev 119708)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2011 Zope Foundation 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.
+#
+##############################################################################
+
+from unittest import TestCase
+
+import zope.component.eventtesting
+from zope.publisher.http import HTTPRequest
+
+from zope.errorview.http import ExceptionViewBase
+from zope.errorview.interfaces import IHandleExceptionEvent
+
+
+class TestEvent(TestCase):
+ def setUp(self):
+ zope.component.eventtesting.setUp()
+ self.request = HTTPRequest('', {})
+
+ def test_event(self):
+ view = ExceptionViewBase(Exception(), self.request)()
+ event = zope.component.eventtesting.getEvents()[0]
+ self.assertEqual(event.request, self.request)
+ self.assertTrue(IHandleExceptionEvent.providedBy(event))
More information about the checkins
mailing list