Log message for revision 110779:
  Wrap exception views in the context of the published object.

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/Zope2/App/startup.py
  U   Zope/branches/2.12/src/Zope2/App/tests/testExceptionHook.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst  2010-04-13 12:12:24 UTC (rev 110778)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-04-13 12:13:26 UTC (rev 110779)
@@ -16,6 +16,7 @@
 - LP #142478:  normalize terms passed to ``PLexicon.queryLexicon`` using
   the lexicon's pipeline (e.g., case flattening, stop word removal, etc.)
 
+- Wrap exception views in the context of the published object.
 
 2.12.4 (2010-04-05)
 -------------------

Modified: Zope/branches/2.12/src/Zope2/App/startup.py
===================================================================
--- Zope/branches/2.12/src/Zope2/App/startup.py 2010-04-13 12:12:24 UTC (rev 
110778)
+++ Zope/branches/2.12/src/Zope2/App/startup.py 2010-04-13 12:13:26 UTC (rev 
110779)
@@ -20,6 +20,7 @@
 from Acquisition import aq_base
 from Acquisition import aq_inner
 from Acquisition import aq_parent
+from Acquisition.interfaces import IAcquirer
 from App.config import getConfiguration
 from time import asctime
 from types import StringType, ListType
@@ -208,6 +209,8 @@
             # Zope 3 uses as well.
             view = queryMultiAdapter((v, REQUEST), name=u'index.html')
             if view is not None:
+                if IAcquirer.providedBy(published):
+                    view = view.__of__(published)
                 v = view()
                 response = REQUEST.RESPONSE
                 response.setStatus(t)

Modified: Zope/branches/2.12/src/Zope2/App/tests/testExceptionHook.py
===================================================================
--- Zope/branches/2.12/src/Zope2/App/tests/testExceptionHook.py 2010-04-13 
12:12:24 UTC (rev 110778)
+++ Zope/branches/2.12/src/Zope2/App/tests/testExceptionHook.py 2010-04-13 
12:13:26 UTC (rev 110779)
@@ -16,6 +16,7 @@
 import unittest
 import logging
 
+import Acquisition
 from zope.component.testing import PlacelessSetup
 from zope.interface.common.interfaces import IException
 from zope.publisher.skinnable import setDefaultSkin
@@ -215,7 +216,7 @@
         self.call_no_exc(hook, None, None, f)
         self.assertEquals(hook.unresolved_conflict_errors, 2)
 
-class Client:
+class Client(Acquisition.Explicit):
 
     def __init__(self):
         self.standard_error_message = True
@@ -320,14 +321,16 @@
         tb = client.messages[0]
         self.failUnless("ConflictError: database conflict error" in tb, tb)
 
-class CustomExceptionView:
+class CustomExceptionView(Acquisition.Explicit):
 
     def __init__(self, context, request):
         self.context = context
         self.request = request
 
     def __call__(self):
-        return "Exception View: %s" % self.context.__class__.__name__
+        return "Exception View: %s\nContext: %s" % (
+                self.context.__class__.__name__,
+                Acquisition.aq_parent(self).__class__.__name__)
 
 def registerExceptionView(for_):
     from zope.interface import Interface
@@ -355,6 +358,7 @@
         self.failUnless(isinstance(v, HTTPResponse), v)
         self.failUnless(v.status == 401, (v.status, 401))
         self.failUnless("Exception View: Unauthorized" in str(v))
+        self.failUnless("Context: StandardClient" in str(v))
 
     def testCustomExceptionViewForbidden(self):
         from ZPublisher.HTTPResponse import HTTPResponse

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to