[Zope-Checkins] CVS: Zope/lib/python/AccessControl - SecurityInfo.py:1.9.48.1 __init__.py:1.11.32.1

Jim Fulton jim@zope.com
Thu, 25 Oct 2001 12:35:15 -0400


Update of /cvs-repository/Zope/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv28851/lib/python/AccessControl

Modified Files:
      Tag: ComponentArchitecture-branch
	SecurityInfo.py __init__.py 
Log Message:
Various changes (in progress) to reflect tutorial.
Checking in to sync with Shane.



=== Zope/lib/python/AccessControl/SecurityInfo.py 1.9 => 1.9.48.1 ===
         pass
 
+
+import Permission
+def protectClass(classobj, perm, methods=(), instance=0):
+    info=ClassSecurityInfo()
+    info.setDefaultAccess('deny')
+    if methods: info.declareProtected(perm, *methods)
+    if instance: info.declareObjectProtected(perm)
+    info.apply(classobj)
+
+    # XXX Below is a hack copied from class_init. This
+    # needs to be a bit more robust and it needs to be factored
+    # out so that it's easier to reuse here.
+    # This will do for now.
+    dict=classobj.__dict__
+    if dict.has_key('__ac_permissions__'):
+        Permission.registerPermissions(
+            classobj.__ac_permissions__)
+        for acp in classobj.__ac_permissions__:
+            pname, mnames = acp[:2]
+            pr=PermissionRole.PermissionRole(pname)
+            for mname in mnames:
+                dict[mname+'__roles__']=pr


=== Zope/lib/python/AccessControl/__init__.py 1.11 => 1.11.32.1 ===
 from SecurityInfo import ACCESS_NONE
 from SecurityInfo import secureModule
+from SecurityInfo import protectClass
 from ZopeGuards import full_read_guard, full_write_guard, safe_builtins
 
 ModuleSecurityInfo('AccessControl').declarePublic('getSecurityManager')