[Checkins] SVN: grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/ Add tests for changed publisher behaviour in case of Unauthorized and handle_errors==False.
Uli Fouquet
uli at gnufix.de
Sun Jul 12 11:36:18 EDT 2009
Log message for revision 101835:
Add tests for changed publisher behaviour in case of Unauthorized and handle_errors==False.
Changed:
A grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/
A grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/__init__.py
A grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/unauthorizednotreraised.py
-=-
Added: grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/__init__.py
===================================================================
--- grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/__init__.py (rev 0)
+++ grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/__init__.py 2009-07-12 15:36:18 UTC (rev 101835)
@@ -0,0 +1 @@
+# this is a package
Added: grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/unauthorizednotreraised.py
===================================================================
--- grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/unauthorizednotreraised.py (rev 0)
+++ grok/branches/ulif-paster-loginhtml/src/grok/ftests/publish/unauthorizednotreraised.py 2009-07-12 15:36:18 UTC (rev 101835)
@@ -0,0 +1,35 @@
+"""
+
+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'
More information about the Checkins
mailing list