[Checkins] SVN: z3c.securitytool/trunk/src/z3c/securitytool/demoSetup.py Added some comments to dummySetup.py

Daniel Blackburn blackburnd at gmail.com
Thu May 8 17:04:53 EDT 2008


Log message for revision 86548:
  Added some comments to dummySetup.py

Changed:
  U   z3c.securitytool/trunk/src/z3c/securitytool/demoSetup.py

-=-
Modified: z3c.securitytool/trunk/src/z3c/securitytool/demoSetup.py
===================================================================
--- z3c.securitytool/trunk/src/z3c/securitytool/demoSetup.py	2008-05-08 21:00:00 UTC (rev 86547)
+++ z3c.securitytool/trunk/src/z3c/securitytool/demoSetup.py	2008-05-08 21:04:53 UTC (rev 86548)
@@ -13,10 +13,17 @@
     
 class CreateStructure(object):
     def __init__(self,event):
+        """ This method gets called on IDatabaseOpenedEvent when running the
+            Demo we add some seemingly random security permissions to the
+            folder tree created below so users of the demo can see what
+            security tool can display
+        """
         db, connection, root, root_folder = getInformationFromEvent(event)
         # Lets get the root folder so we can assign some permissions to
         # specific contexts
         root=zapi.getRoot(root_folder)
+
+        # If the following folders do not exist... lets create them
         if 'Folder1' not in root:
             root['Folder1'] = Folder()
 
@@ -26,19 +33,22 @@
         if 'Folder3' not in root['Folder1']['Folder2']:
             root['Folder1']['Folder2']['Folder3'] = Folder()
 
+        # Lets get the list of all principals on the system.
         sysPrincipals = zapi.principals()
-        principals = [x.id for x in sysPrincipals.getPrincipals('') if x.id != 'group1']
+        principals = [x.id for x in sysPrincipals.getPrincipals('')
+                      if x.id != 'group1']
 
-
+# Here is where we begin to set the permissions for the root context level
         roleManager = IPrincipalRoleManager(root)
         permManager = IPrincipalPermissionManager(root)
-        
         roleManager.assignRoleToPrincipal('zope.Editor', 'zope.group1')
 
+        # Here we assign the group group1 to zope.daniel
         daniel  = sysPrincipals.getPrincipal('zope.daniel')
         group1  = sysPrincipals.getPrincipal('zope.group1')
         daniel.groups.append(group1)
 
+        # Here we assign the group group1 to zope.randy
         randy  = sysPrincipals.getPrincipal('zope.randy')
         group1  = sysPrincipals.getPrincipal('zope.group1')
         randy.groups.append(group1)
@@ -55,6 +65,8 @@
                                               principal)
 
 
+# Here is where we begin to set the permissions for the context level of
+# Folder1.
         roleManager = IPrincipalRoleManager(root['Folder1'])
         permManager = IPrincipalPermissionManager(root['Folder1'])
 
@@ -73,14 +85,14 @@
                                               principal)
 
 
-
+# Here is where we begin to set the permissions for the context level of
+# /root/Folder1/Folder2.
         roleManager = IPrincipalRoleManager(root['Folder1']['Folder2'])
         permManager = IPrincipalPermissionManager(root['Folder1']['Folder2'])
 
         roleManager.assignRoleToPrincipal('zope.Janitor', 'zope.markus')
         roleManager.assignRoleToPrincipal('zope.Writer', 'zope.daniel')
 
-
         permManager.denyPermissionToPrincipal('concord.CreateArticle',
                                               'zope.daniel')
         permManager.denyPermissionToPrincipal('concord.CreateIssue',
@@ -92,8 +104,14 @@
         permManager.denyPermissionToPrincipal('concord.CreateIssue',
                                               'zope.anybody')
 
-        roleManager = IPrincipalRoleManager(root['Folder1']['Folder2']['Folder3'])
-        permManager = IPrincipalPermissionManager(root['Folder1']['Folder2']['Folder3'])
+# Here is where we begin to set the permissions for the context level of
+# /root/Folder1/Folder2/Folder3.
+        roleManager = IPrincipalRoleManager(root['Folder1']\
+                                                ['Folder2']\
+                                                ['Folder3'])
+        permManager = IPrincipalPermissionManager(root['Folder1']\
+                                                      ['Folder2']\
+                                                      ['Folder3'])
 
         
         roleManager.removeRoleFromPrincipal('zope.Writer','zope.daniel')



More information about the Checkins mailing list