[Checkins] SVN: grokcore.security/trunk/s What the heck, zope.security pulls in the universe itself already, so why

Philipp von Weitershausen philikon at philikon.de
Tue Jul 29 17:21:53 EDT 2008


Log message for revision 88988:
  What the heck, zope.security pulls in the universe itself already, so why
  not depend on zope.app.security instead of inlining this function...
  

Changed:
  U   grokcore.security/trunk/setup.py
  U   grokcore.security/trunk/src/grokcore/security/util.py

-=-
Modified: grokcore.security/trunk/setup.py
===================================================================
--- grokcore.security/trunk/setup.py	2008-07-29 21:19:46 UTC (rev 88987)
+++ grokcore.security/trunk/setup.py	2008-07-29 21:21:52 UTC (rev 88988)
@@ -37,6 +37,7 @@
                       'zope.interface',
                       'zope.component',
                       'zope.security',
+                      'zope.app.security',
                       'zope.configuration',
                       'zope.testing',
                       ],

Modified: grokcore.security/trunk/src/grokcore/security/util.py
===================================================================
--- grokcore.security/trunk/src/grokcore/security/util.py	2008-07-29 21:19:46 UTC (rev 88987)
+++ grokcore.security/trunk/src/grokcore/security/util.py	2008-07-29 21:21:52 UTC (rev 88988)
@@ -17,8 +17,7 @@
 from zope.component import queryUtility
 from zope.security.checker import NamesChecker, defineChecker
 from zope.security.interfaces import IPermission
-from zope.security.checker import getCheckerForInstancesOf
-from zope.security.checker import Checker, CheckerPublic
+from zope.app.security.protectclass import protectName
 
 def protect_name(class_, name, permission=None):
     # Define an attribute checker using zope.app.security's
@@ -30,23 +29,8 @@
     else:
         check_permission(class_, permission)
 
-    # The rest of this function is a verbatim copy of
-    # zope.app.security.protectclass.protectName.  Unfortunately,
-    # zope.app.security pretty much pulls in the whole universe which
-    # we'd like to avoid for this simple, barebones package.
-    checker = getCheckerForInstancesOf(class_)
-    if checker is None:
-        checker = Checker({}, {})
-        defineChecker(class_, checker)
+    protectName(class_, name, permission)
 
-    if permission == 'zope.Public':
-        # Translate public permission to CheckerPublic
-        permission = CheckerPublic
-
-    # We know a dictionary was used because we set it
-    protections = checker.get_permissions
-    protections[name] = permission
-
 def make_checker(factory, view_factory, permission, method_names=None):
     """Make a checker for a view_factory associated with factory.
 



More information about the Checkins mailing list