[Checkins] SVN: grok/trunk/doc/reference/ Updating reference to talk about zope.View being the default

Martijn Faassen faassen at startifact.com
Fri Oct 9 11:27:34 EDT 2009


Log message for revision 104971:
  Updating reference to talk about zope.View being the default
  permission, and to talk about direct permission references.
  
  I'm not sure whether direct permission references work in roles. If
  not, that is a bug, and we should fix it asap. The docs now say it should. :)
  

Changed:
  U   grok/trunk/doc/reference/components.rst
  U   grok/trunk/doc/reference/directives.rst

-=-
Modified: grok/trunk/doc/reference/components.rst
===================================================================
--- grok/trunk/doc/reference/components.rst	2009-10-09 15:24:44 UTC (rev 104970)
+++ grok/trunk/doc/reference/components.rst	2009-10-09 15:27:34 UTC (rev 104971)
@@ -1257,7 +1257,7 @@
 Permissions are used to protect Views so that they can only be called by
 an authenticated principal. If a View in Grok does not have a `grok.require`
 directive declaring a permission needed to use the View, then the default
-anonymously viewable `grok.Public` permission used.
+anonymously viewable `zope.View` permission used.
 
 .. class:: grok.Permission
 
@@ -1342,7 +1342,8 @@
 
     :func:`grok.permissions(permissions)`
 
-        Required. Declare the permissions granted to this role.
+        Required. Declare the permissions granted to this role. These
+        can refer by permission class or by name.
 
     :func:`grok.title(title)`
 
@@ -1379,8 +1380,10 @@
         grok.name('paint.Artist')
         grok.title('Artist')
         grok.description('An artist owns the paintings that they create.')
-        grok.permissions(
-            'paint.ViewPainting', 'paint.EditPainting', 'paint.ErasePainting')
+        grok.permissions(ViewPainting, EditPainting, ErasePainting)
+        # alternatively, use permission names
+        # grok.permissions(
+        #    'paint.ViewPainting', 'paint.EditPainting', 'paint.ErasePainting')
 
     class CavePainting(grok.View):
         grok.context(zope.interface.Interface)

Modified: grok/trunk/doc/reference/directives.rst
===================================================================
--- grok/trunk/doc/reference/directives.rst	2009-10-09 15:24:44 UTC (rev 104970)
+++ grok/trunk/doc/reference/directives.rst	2009-10-09 15:27:34 UTC (rev 104971)
@@ -467,10 +467,13 @@
 A class level directive used to protect a View by requiring a
 certain permission.
 
-`permission` -- the name of the permission that is required
+`permission` -- the class of the :class:`grok.Permission` subclass that
+                is required. Alternatively, the name of the permission that is
+                required
 
-**Example 1: Define a Permission and use it to protect a View**
 
+**Example 1 Define a Permission and use it to protect a View, using permission class**
+
 .. code-block:: python
 
     import grok
@@ -481,6 +484,20 @@
 
     class Index(grok.View):
         grok.context(zope.interface.Interface)
+        grok.require(Read)
+
+**Example 2: Define a Permission and use it to protect a View, using permission name**
+
+.. code-block:: python
+
+    import grok
+    import zope.interface
+    
+    class Read(grok.Permission):
+        grok.name('mypackage.Read')
+
+    class Index(grok.View):
+        grok.context(zope.interface.Interface)
         grok.require('mypackage.Read')
 
 .. seealso::



More information about the checkins mailing list