[Checkins] SVN: grok/trunk/ Grok will no longer register an IReRaise adapter for IUnauthorized by default as that changed behaviour globally when it really only is needed during debugging using the evalexecption middleware. Instead grokproject will create debug.ini files that use the new debug_application_factory from grokcore.startup that allows to configure what exceptions not to re-raise during debugging. Ported from the 1.0 maintenance branch.

Jan-Wijbrand Kolman janwijbrand at gmail.com
Fri Oct 2 07:59:18 EDT 2009


Log message for revision 104746:
  Grok will no longer register an IReRaise adapter for IUnauthorized by default as that changed behaviour globally when it really only is needed during debugging using the evalexecption middleware. Instead grokproject will create debug.ini files that use the new debug_application_factory from grokcore.startup that allows to configure what exceptions not to re-raise during debugging. Ported from the 1.0 maintenance branch.

Changed:
  U   grok/trunk/doc/upgrade.txt
  U   grok/trunk/src/grok/configure.zcml
  D   grok/trunk/src/grok/ftests/publish/
  U   grok/trunk/src/grok/ftests/security/json.py
  U   grok/trunk/src/grok/publication.py

-=-
Modified: grok/trunk/doc/upgrade.txt
===================================================================
--- grok/trunk/doc/upgrade.txt	2009-10-02 11:56:03 UTC (rev 104745)
+++ grok/trunk/doc/upgrade.txt	2009-10-02 11:59:18 UTC (rev 104746)
@@ -109,17 +109,22 @@
 
   When using this profile it is not the ``zope.publisher`` that handles the
   exceptions that are raised, but a special middleware is. This middleware
-  then provides a pdb-like debugging user interdace in the browser.
+  then provides a pdb-like debugging user interface in the browser.
 
-  Note that the ``IUnauthorized`` exception is treated specially: Grok will
-  make sure that this types of exception is actaully still handled by
-  ``zope.publisher`` in order to make login forms or Basic Auth
-  authentication still function properly.
+  Note that this includes IUnauthorized exceptions not being handled by zope,
+  that would've prevented any login mechanism to work when debugging.
 
-  Also note that as a consequence the ``handleErrors`` attribute on
-  ``zope.testbrowser.testing.Browser`` instances used in functional tests
-  does not effect the ``IUnauthorized`` exception.
+  However, there is a configuration option called ``exempt-exceptions``
+  available in the debug.ini that determines what exceptions should still be
+  handled by zope. By default debug.ini files created by grokproject will
+  exempt the IUnauthorized exceptions from being reraised and thus normal
+  authentication mechanism continue to work::
 
+    [app:zope]
+    use = egg:${egg}#debug
+    filter-with = translogger
+    exempt-exceptions = zope.security.interfaces.IUnauthorized
+
   Interpreter name has been changed from ``bin/python`` to
   ``bin/grokpy`` to avoid conflicts with virtualenv.
 

Modified: grok/trunk/src/grok/configure.zcml
===================================================================
--- grok/trunk/src/grok/configure.zcml	2009-10-02 11:56:03 UTC (rev 104745)
+++ grok/trunk/src/grok/configure.zcml	2009-10-02 11:59:18 UTC (rev 104746)
@@ -78,12 +78,6 @@
       priority="1"
       />
 
-  <adapter
-      factory=".publication.DontReRaiseUnauthorizedAdapter"
-      for="zope.security.interfaces.IUnauthorized"
-      provides="zope.publisher.interfaces.IReRaiseException"
-      />
-
   <!-- need to grok this for some basic REST support -->
   <grok:grok package=".rest" />
 

Modified: grok/trunk/src/grok/ftests/security/json.py
===================================================================
--- grok/trunk/src/grok/ftests/security/json.py	2009-10-02 11:56:03 UTC (rev 104745)
+++ grok/trunk/src/grok/ftests/security/json.py	2009-10-02 11:59:18 UTC (rev 104746)
@@ -3,7 +3,6 @@
 
   >>> from zope.testbrowser.testing import Browser
   >>> browser = Browser()
-  >>> browser.handleErrors = False
 
 We can access the public method just fine::
 
@@ -24,7 +23,7 @@
   >>> browser.open('http://localhost/dance')
   >>> print browser.contents
   {"Manfred doesn't like to dance.": ""}
-  
+
 """
 
 import grok

Modified: grok/trunk/src/grok/publication.py
===================================================================
--- grok/trunk/src/grok/publication.py	2009-10-02 11:56:03 UTC (rev 104745)
+++ grok/trunk/src/grok/publication.py	2009-10-02 11:59:18 UTC (rev 104746)
@@ -176,20 +176,3 @@
     def __call__(self):
         request, publication = super(GrokHTTPFactory, self).__call__()
         return request, GrokHTTPPublication
-
-def DontReRaiseUnauthorizedAdapter(context):
-    """Adapter to indicate we don't want Unauthorized to be reraised.
-
-    When running the publisher in ``handle_errors=False``-mode, which
-    happens for instance when running Grok in a WSGI pipeline with a
-    debugger middleware enabled, we don't want IUnauthorized errors to
-    be reraised during publishing.
-
-    We can indicate this by providing an adapter, that adapts
-    exceptions of this type (`IUnauthorized`) to
-    `zope.publisher.interfaces.IReRaiseException` and returning
-    ``False`` when being called.
-    """
-    def shouldBeReRaised():
-        return False
-    return shouldBeReRaised



More information about the checkins mailing list