Skip to content

Commit

Permalink
Grok will no longer register an IReRaise adapter for IUnauthorized by…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
janwijbrand committed Oct 2, 2009
1 parent 027a3e5 commit 748a461
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 69 deletions.
21 changes: 13 additions & 8 deletions doc/upgrade.txt
Expand Up @@ -109,16 +109,21 @@ Upgrading to 1.0b2 (2009-09-15)

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.
Expand Down
6 changes: 0 additions & 6 deletions src/grok/configure.zcml
Expand Up @@ -79,12 +79,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" />

Expand Down
1 change: 0 additions & 1 deletion src/grok/ftests/publish/__init__.py

This file was deleted.

35 changes: 0 additions & 35 deletions src/grok/ftests/publish/unauthorizednotreraised.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/grok/ftests/security/json.py
Expand Up @@ -3,7 +3,6 @@
>>> from zope.testbrowser.testing import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
We can access the public method just fine::
Expand All @@ -24,7 +23,7 @@
>>> browser.open('http://localhost/dance')
>>> print browser.contents
{"Manfred doesn't like to dance.": ""}
"""

import grok
Expand Down
17 changes: 0 additions & 17 deletions src/grok/publication.py
Expand Up @@ -176,20 +176,3 @@ class GrokHTTPFactory(HTTPFactory):
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

0 comments on commit 748a461

Please sign in to comment.