[Checkins] SVN: grokcore.security/trunk/src/grokcore/security/tests/security/protect_name.py another test

Philipp von Weitershausen philikon at philikon.de
Tue Jul 29 17:06:27 EDT 2008


Log message for revision 88986:
  another test
  

Changed:
  A   grokcore.security/trunk/src/grokcore/security/tests/security/protect_name.py

-=-
Added: grokcore.security/trunk/src/grokcore/security/tests/security/protect_name.py
===================================================================
--- grokcore.security/trunk/src/grokcore/security/tests/security/protect_name.py	                        (rev 0)
+++ grokcore.security/trunk/src/grokcore/security/tests/security/protect_name.py	2008-07-29 21:06:26 UTC (rev 88986)
@@ -0,0 +1,22 @@
+"""
+A permission has to be defined first (using grok.Permission for example)
+before it can be used in grok.require().
+
+  >>> grok.testing.grok(__name__)
+
+  >>> from zope.security.checker import ProxyFactory, getChecker
+  >>> obj = ProtectedObject()
+  >>> obj = ProxyFactory(obj)
+  >>> checker = getChecker(obj)
+  >>> checker.permission_id('protected')
+  'the.permission'
+"""
+import grokcore.security as grok
+
+class ThePermission(grok.Permission):
+    grok.name('the.permission')
+
+class ProtectedObject(grok.Context):
+    grok.require(ThePermission)
+
+    protected = 'this is protected'


Property changes on: grokcore.security/trunk/src/grokcore/security/tests/security/protect_name.py
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Checkins mailing list