[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/ContentDirective - ContentDirective.py:1.8 meta.zcml:1.4

Jim Fulton jim@zope.com
Tue, 1 Oct 2002 08:48:20 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ContentDirective
In directory cvs.zope.org:/tmp/cvs-serv18244/lib/python/Zope/App/ContentDirective

Modified Files:
	ContentDirective.py meta.zcml 
Log Message:
Added the ability to provide permissions for setting selected
attributes.



=== Zope3/lib/python/Zope/App/ContentDirective/ContentDirective.py 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/App/ContentDirective/ContentDirective.py:1.7	Sun Sep  1 14:29:57 2002
+++ Zope3/lib/python/Zope/App/ContentDirective/ContentDirective.py	Tue Oct  1 08:47:49 2002
@@ -23,7 +23,7 @@
 from Zope.Configuration.Action import Action
 from Zope.App.ComponentArchitecture.ClassFactory import ClassFactory
 from Zope.App.Security.protectClass \
-    import protectLikeUnto, protectName, checkPermission
+    import protectLikeUnto, protectName, checkPermission, protectSetAttribute
 from Zope.Security.Proxy import ProxyFactory
 from Zope.Security.Checker import NamesChecker
 
@@ -61,7 +61,7 @@
 
     def require(self, _context,
                 permission=None, attributes=None, interface=None,
-                like_class=None):
+                like_class=None, set_attributes=None):
         """Require a the permission to access a specific aspect"""
 
         if like_class:
@@ -69,7 +69,7 @@
         else:
             r = []
 
-        if not (interface or attributes):
+        if not (interface or attributes or set_attributes):
             if r:
                 return r
             raise ConfigurationError("Nothing required")
@@ -82,6 +82,8 @@
             self.__protectByInterface(interface, permission, r)
         if attributes:
             self.__protectNames(attributes, permission, r)
+        if set_attributes:
+            self.__protectSetAttributes(set_attributes, permission, r)
 
 
         return r
@@ -118,6 +120,13 @@
         "Set a permission on a bunch of names."
         for name in names.split():
             self.__protectName(name.strip(), permission_id, r)
+            
+    def __protectSetAttributes(self, names, permission_id, r):
+        "Set a permission on a bunch of names."
+        for name in names.split():
+            r.append((
+                ('protectSetAttribute', self.__class, name),
+                protectSetAttribute, (self.__class, name, permission_id)))
 
 
     def __call__(self):


=== Zope3/lib/python/Zope/App/ContentDirective/meta.zcml 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/ContentDirective/meta.zcml:1.3	Thu Jun 20 16:00:19 2002
+++ Zope3/lib/python/Zope/App/ContentDirective/meta.zcml	Tue Oct  1 08:47:49 2002
@@ -8,7 +8,8 @@
       <subdirective name="implements"
                     attributes="interface" />
       <subdirective name="require"
-                    attributes="permission attributes interface like_class" />
+                    attributes="permission attributes interface
+                                like_class set_attributes" />
       <subdirective name="allow"
                     attributes="attributes interface" />
       <subdirective name="factory"