diff --git a/doc/upgrade.txt b/doc/upgrade.txt index cf023c87..075cc6e7 100644 --- a/doc/upgrade.txt +++ b/doc/upgrade.txt @@ -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. diff --git a/src/grok/configure.zcml b/src/grok/configure.zcml index 82d8faae..79bcce87 100644 --- a/src/grok/configure.zcml +++ b/src/grok/configure.zcml @@ -79,12 +79,6 @@ priority="1" /> - - diff --git a/src/grok/ftests/publish/__init__.py b/src/grok/ftests/publish/__init__.py deleted file mode 100644 index a0037596..00000000 --- a/src/grok/ftests/publish/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# this is a package diff --git a/src/grok/ftests/publish/unauthorizednotreraised.py b/src/grok/ftests/publish/unauthorizednotreraised.py deleted file mode 100644 index b1efb38c..00000000 --- a/src/grok/ftests/publish/unauthorizednotreraised.py +++ /dev/null @@ -1,35 +0,0 @@ -""" - -When the publisher is called in ``handle_errors=False`` mode, as -happens when running Grok with paster and WSGI debugger middleware, -IUnauthorized exceptions are handled anyway by the publisher. - -We create a simple site with a protected ``index`` view: - - >>> root = getRootFolder() - >>> root['app'] = App() - -When we call the protected view with ``handle_errors`` set to -``False``, we will get no exception but instead an HTTP error: - - >>> from zope.app.testing.functional import HTTPCaller - >>> http_call = HTTPCaller() - - >>> print http_call("GET /app/@@index HTTP/1.1" + chr(13), - ... handle_errors=False) - HTTP/1.1 401 Unauthorized - ... - -""" -import grok - -class ManagerPerm(grok.Permission): - grok.name('grok.Manager') - -class App(grok.Application, grok.Container): - pass - -class Index(grok.View): - grok.require('grok.Manager') - def render(self): - return 'Hello from protected view' diff --git a/src/grok/ftests/security/json.py b/src/grok/ftests/security/json.py index feb2d82e..2793ea0e 100644 --- a/src/grok/ftests/security/json.py +++ b/src/grok/ftests/security/json.py @@ -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 diff --git a/src/grok/publication.py b/src/grok/publication.py index 180dafc8..b46223bf 100644 --- a/src/grok/publication.py +++ b/src/grok/publication.py @@ -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