[Checkins] SVN: grok/trunk/ declare the name "index" as default view name for error views too. this removes possible confusion for developers who want to create custom error views in a grok context. note that the error view components in grok.components are not active unless subclassed. update changelog accordingly.

Jan-Wijbrand Kolman janwijbrand at gmail.com
Wed Jul 13 06:09:38 EDT 2011


Log message for revision 122171:
  declare the name "index" as default view name for error views too. this removes possible confusion for developers who want to create custom error views in a grok context. note that the error view components in grok.components are not active unless subclassed. update changelog accordingly.

Changed:
  U   grok/trunk/CHANGES.txt
  U   grok/trunk/src/grok/components.py
  U   grok/trunk/src/grok/configure.zcml
  U   grok/trunk/src/grok/ftesting.zcml
  U   grok/trunk/src/grok/ftests/errorviews/errorviews.py
  U   grok/trunk/src/grok/ftests/security/handle_exception.py

-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt	2011-07-13 09:58:57 UTC (rev 122170)
+++ grok/trunk/CHANGES.txt	2011-07-13 10:09:38 UTC (rev 122171)
@@ -4,8 +4,9 @@
 1.8 (unreleased)
 ================
 
-- Nothing changed yet.
+- Expose the ContentProvider component from grokcore.view
 
+- Declare the name "index" as default view name for error views.
 
 1.7 (2011-05-26)
 ================

Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py	2011-07-13 09:58:57 UTC (rev 122170)
+++ grok/trunk/src/grok/components.py	2011-07-13 10:09:38 UTC (rev 122171)
@@ -157,11 +157,12 @@
     """Base class for rendering views for uncaught exceptions that occur during
     the application run-time and are not otherwise rendered.
 
-    Note that when this class in not subclassed, the default error view
-    from zope.errorview is being rendered.
+    Note that when this class in not subclassed, the default error view from
+    zope.errorview is being rendered.
     """
+    grok.baseclass()
     grok.context(IException)
-    grok.name('index.html')
+    grok.name('index')
 
     def update(self):
         return zope.errorview.browser.ExceptionView.update(self)
@@ -182,11 +183,12 @@
 class NotFoundView(View, zope.errorview.browser.NotFoundView):
     """Base class for rendering views for INotFound exceptions.
 
-    Note that when this class in not subclassed, the default error view
-    from zope.errorview is being rendered.
+    Note that when this class in not subclassed, the default error view from
+    zope.errorview is being rendered.
     """
+    grok.baseclass()
     grok.context(INotFound)
-    grok.name('index.html')
+    grok.name('index')
 
     def update(self):
         return zope.errorview.browser.NotFoundView.update(self)
@@ -207,11 +209,12 @@
 class UnauthorizedView(View, zope.errorview.browser.UnauthorizedView):
     """Base class for rendering views for IUnauthorized exceptions.
 
-    Note that when this class in not subclassed, the default error view
-    from zope.errorview is being rendered.
+    Note that when this class in not subclassed, the default error view from
+    zope.errorview is being rendered.
     """
+    grok.baseclass()
     grok.context(IUnauthorized)
-    grok.name('index.html')
+    grok.name('index')
 
     def update(self):
         return zope.errorview.browser.UnauthorizedView.update(self)

Modified: grok/trunk/src/grok/configure.zcml
===================================================================
--- grok/trunk/src/grok/configure.zcml	2011-07-13 09:58:57 UTC (rev 122170)
+++ grok/trunk/src/grok/configure.zcml	2011-07-13 10:09:38 UTC (rev 122171)
@@ -56,4 +56,30 @@
       name="index"
       />
 
+  <browser:defaultView
+    for="zope.interface.common.interfaces.IException"
+    name="index"
+  />
+
+  <browser:page
+    for="zope.interface.common.interfaces.IException"
+    class="zope.errorview.browser.ExceptionView"
+    name="index"
+    permission="zope.Public"
+  />
+
+  <browser:page
+    for="zope.security.interfaces.IUnauthorized"
+    class="zope.errorview.browser.UnauthorizedView"
+    name="index"
+    permission="zope.Public"
+  />
+
+  <browser:page
+    for="zope.publisher.interfaces.INotFound"
+    class="zope.errorview.browser.NotFoundView"
+    name="index"
+    permission="zope.Public"
+  />
+
 </configure>

Modified: grok/trunk/src/grok/ftesting.zcml
===================================================================
--- grok/trunk/src/grok/ftesting.zcml	2011-07-13 09:58:57 UTC (rev 122170)
+++ grok/trunk/src/grok/ftesting.zcml	2011-07-13 10:09:38 UTC (rev 122171)
@@ -13,8 +13,6 @@
   <include package="grok" />
   <grok:grok package="grok.ftests" />
 
-  <browser:defaultView name="index.html" />
-
   <securityPolicy
       component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
       />

Modified: grok/trunk/src/grok/ftests/errorviews/errorviews.py
===================================================================
--- grok/trunk/src/grok/ftests/errorviews/errorviews.py	2011-07-13 09:58:57 UTC (rev 122170)
+++ grok/trunk/src/grok/ftests/errorviews/errorviews.py	2011-07-13 10:09:38 UTC (rev 122171)
@@ -5,7 +5,7 @@
 
   >>> from zope.component import getMultiAdapter
   >>> from zope.publisher.browser import TestRequest
-  >>> view = getMultiAdapter((Exception(), TestRequest()), name='index.html')
+  >>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
   >>> print view()
   A system error occurred.
 
@@ -19,14 +19,14 @@
   >>> from zope.publisher.interfaces import NotFound
   >>> request = TestRequest()
   >>> error = NotFound(object(), request)
-  >>> view = getMultiAdapter((error, request), name='index.html')
+  >>> view = getMultiAdapter((error, request), name='index')
   >>> print view()
   The requested resource can not be found.
 
   >>> from zope.security.interfaces import Unauthorized
   >>> request = TestRequest()
   >>> request.setPrincipal(MockPrincipal())
-  >>> view = getMultiAdapter((Unauthorized(), request), name='index.html')
+  >>> view = getMultiAdapter((Unauthorized(), request), name='index')
   >>> print view()
   Access to the requested resource is forbidden.
 
@@ -40,7 +40,7 @@
   >>> grok_component('MyExceptionView', MyExceptionView)
   True
 
-  >>> view = getMultiAdapter((Exception(), TestRequest()), name='index.html')
+  >>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
   >>> print view()
   This is my idea of an exception view.
 
@@ -53,7 +53,7 @@
 
   >>> request = TestRequest()
   >>> error = NotFound(object(), request)
-  >>> view = getMultiAdapter((error, request), name='index.html')
+  >>> view = getMultiAdapter((error, request), name='index')
   >>> print view()
   This is my idea of a not found view.
 
@@ -66,7 +66,7 @@
 
   >>> request = TestRequest()
   >>> request.setPrincipal(MockPrincipal())
-  >>> view = getMultiAdapter((Unauthorized(), request), name='index.html')
+  >>> view = getMultiAdapter((Unauthorized(), request), name='index')
   >>> print view()
   This is my idea of an unauthorized view.
 
@@ -75,7 +75,7 @@
   >>> grok_component('WithTemplate', WithTemplate)
   True
 
-  >>> view = getMultiAdapter((Exception(), TestRequest()), name='index.html')
+  >>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
   >>> print view()
   <html>
   <body>

Modified: grok/trunk/src/grok/ftests/security/handle_exception.py
===================================================================
--- grok/trunk/src/grok/ftests/security/handle_exception.py	2011-07-13 09:58:57 UTC (rev 122170)
+++ grok/trunk/src/grok/ftests/security/handle_exception.py	2011-07-13 10:09:38 UTC (rev 122171)
@@ -35,7 +35,7 @@
 class CaveErrorView(grok.View):
     """Default view for the CaveWasRobbedError.
     """
-    grok.name("index.html")
+    grok.name("index")
     grok.context(CaveWasRobbedError)
 
     def render(self):



More information about the checkins mailing list