[Grok-dev] grok.require() can refer to a class too, Was: sprint mini-report 2

Jan-Wijbrand Kolman janwijbrand at gmail.com
Fri May 2 06:26:06 EDT 2008


Martijn Faassen wrote:
 > * grok.require can now refer to Permissions directly (on a branch),
 > instead of only on a name basis.

This branch has just now been merged with the trunk. Now I should update 
the grok_overview.rst documentation... And the notes on using 
permissions on the grok.zope.org site of course too.


Anway, when you define your own permission in your Grok-based 
application, instead of doing:

...
   class PermissionToSmash(grok.Permission):
       grok.name('smash')

   class ASmashingView(grok.View):
       grok.require('smash')
...

you can now do:

...
   class PermissionToSmash(grok.Permission):
       grok.name('smash')

   class ASmashingView(grok.View):
       grok.require(PermissionToSmash)
...


Notes:

* your permission components do still need a grok.name() directive (as 
they always did), because on a Zope-level it is this name that is used 
for (local) grants.

* you can still use the grok.require() directive with a permission name, 
e.g. in case of permissions defined outside your own application, like 
'zope.View'.

* Grok defines a special "permission" called Public. So, in case you 
explicitly want to "require" the 'zope.Public' "permission" you can do this:

...
   class AnotherSmashingView(grok.View):
       grok.require(grok.Public)
...


regards,
jw



More information about the Grok-dev mailing list