[Checkins] SVN: grokcore.security/trunk/ split the grokkker from meta.py into meta/role.py and meta/permission.py

Jan Wijbrand Kolman cvs-admin at zope.org
Mon Apr 30 15:41:16 UTC 2012


Log message for revision 125448:
  split the grokkker from meta.py into meta/role.py and meta/permission.py

Changed:
  U   grokcore.security/trunk/buildout.cfg
  U   grokcore.security/trunk/setup.py
  A   grokcore.security/trunk/src/grokcore/security/meta/
  A   grokcore.security/trunk/src/grokcore/security/meta/__init__.py
  A   grokcore.security/trunk/src/grokcore/security/meta/permission.py
  A   grokcore.security/trunk/src/grokcore/security/meta/role.py
  A   grokcore.security/trunk/src/grokcore/security/meta-minimal.zcml
  D   grokcore.security/trunk/src/grokcore/security/meta.py
  U   grokcore.security/trunk/src/grokcore/security/meta.zcml

-=-
Modified: grokcore.security/trunk/buildout.cfg
===================================================================
--- grokcore.security/trunk/buildout.cfg	2012-04-30 14:50:30 UTC (rev 125447)
+++ grokcore.security/trunk/buildout.cfg	2012-04-30 15:41:12 UTC (rev 125448)
@@ -10,11 +10,13 @@
 
 [interpreter]
 recipe = zc.recipe.egg
-eggs = grokcore.security
+eggs =
+  grokcore.security[role]
 interpreter = python
 
 [test]
 recipe = zc.recipe.testrunner
-eggs = grokcore.security
-       grokcore.security[test]
+eggs =
+  grokcore.security
+  grokcore.security[test]
 defaults = ['--tests-pattern', '^f?tests$', '-v']

Modified: grokcore.security/trunk/setup.py
===================================================================
--- grokcore.security/trunk/setup.py	2012-04-30 14:50:30 UTC (rev 125447)
+++ grokcore.security/trunk/setup.py	2012-04-30 15:41:12 UTC (rev 125448)
@@ -14,6 +14,7 @@
     'grokcore.view[test]',
     'zope.app.wsgi',
     'zope.configuration',
+    'zope.securitypolicy',
     'zope.testing',
     ]
 
@@ -45,8 +46,12 @@
         'zope.component',
         'zope.interface',
         'zope.security',
-        'zope.securitypolicy',
         ],
     tests_require=tests_require,
-    extras_require={'test': tests_require},
+    extras_require={
+        'role': [
+            'zope.securitypolicy',
+            ],
+        'test': tests_require
+        },
 )

Copied: grokcore.security/trunk/src/grokcore/security/meta/permission.py (from rev 125443, grokcore.security/trunk/src/grokcore/security/meta.py)
===================================================================
--- grokcore.security/trunk/src/grokcore/security/meta/permission.py	                        (rev 0)
+++ grokcore.security/trunk/src/grokcore/security/meta/permission.py	2012-04-30 15:41:12 UTC (rev 125448)
@@ -0,0 +1,52 @@
+#############################################################################
+#
+# Copyright (c) 2006-2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Grokkers for security-related components."""
+
+import martian
+import grokcore.component
+import grokcore.component.util
+import grokcore.security
+
+from zope.security.interfaces import IPermission
+from martian.error import GrokError
+
+
+def default_fallback_to_name(factory, module, name, **data):
+    return name
+
+class PermissionGrokker(martian.ClassGrokker):
+    martian.component(grokcore.security.Permission)
+    martian.priority(1500)
+    martian.directive(grokcore.component.name)
+    martian.directive(grokcore.component.title,
+                      get_default=default_fallback_to_name)
+    martian.directive(grokcore.component.description)
+
+    def execute(self, factory, config, name, title, description, **kw):
+        if not name:
+            raise GrokError(
+                "A permission needs to have a dotted name for its id. Use "
+                "grok.name to specify one.", factory)
+        # We can safely convert to unicode, since the directives make sure
+        # it is either unicode already or ASCII.
+        permission = factory(unicode(name), unicode(title),
+                             unicode(description))
+
+        config.action(
+            discriminator=('utility', IPermission, name),
+            callable=grokcore.component.util.provideUtility,
+            args=(permission, IPermission, name),
+            order=-1 # need to do this early in the process
+            )
+        return True

Copied: grokcore.security/trunk/src/grokcore/security/meta/role.py (from rev 125443, grokcore.security/trunk/src/grokcore/security/meta.py)
===================================================================
--- grokcore.security/trunk/src/grokcore/security/meta/role.py	                        (rev 0)
+++ grokcore.security/trunk/src/grokcore/security/meta/role.py	2012-04-30 15:41:12 UTC (rev 125448)
@@ -0,0 +1,75 @@
+#############################################################################
+#
+# Copyright (c) 2006-2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Grokkers for security-related components."""
+
+import martian
+import grokcore.component
+import grokcore.component.util
+import grokcore.security
+
+from martian.error import GrokError
+
+from zope.i18nmessageid import Message
+from zope.securitypolicy.rolepermission import rolePermissionManager
+from zope.securitypolicy.interfaces import IRole
+
+from grokcore.security.directive import permissions
+from grokcore.security.components import Role
+from grokcore.security.meta.permission import PermissionGrokker
+from grokcore.security.meta.permission import default_fallback_to_name
+
+
+class RoleGrokker(martian.ClassGrokker):
+    """Grokker for components subclassed from `grok.Role`.
+
+    Each role is registered as a global utility providing the service
+    `IRole` under its own particular name, and then granted every
+    permission named in its `grok.permission()` directive.
+
+    """
+    martian.component(Role)
+    martian.priority(martian.priority.bind().get(PermissionGrokker()) - 1)
+    martian.directive(grokcore.component.name)
+    martian.directive(
+        grokcore.component.title, get_default=default_fallback_to_name)
+    martian.directive(grokcore.component.description)
+    martian.directive(permissions)
+
+    def execute(self, factory, config, name, title, description,
+                permissions, **kw):
+        if not name:
+            raise GrokError(
+                "A role needs to have a dotted name for its id. Use "
+                "grok.name to specify one.", factory)
+        # We can safely convert to unicode, since the directives makes sure
+        # it is either unicode already or ASCII.
+        if not isinstance(title, Message):
+            title = unicode(title)
+        if not isinstance(description, Message):
+            description = unicode(description)
+        role = factory(unicode(name), title, description)
+
+        config.action(
+            discriminator=('utility', IRole, name),
+            callable=grokcore.component.util.provideUtility,
+            args=(role, IRole, name),
+            )
+
+        for permission in permissions:
+            config.action(
+                discriminator=('grantPermissionToRole', permission, name),
+                callable=rolePermissionManager.grantPermissionToRole,
+                args=(permission, name),
+                )
+        return True

Copied: grokcore.security/trunk/src/grokcore/security/meta-minimal.zcml (from rev 125437, grokcore.security/trunk/src/grokcore/security/meta.zcml)
===================================================================
--- grokcore.security/trunk/src/grokcore/security/meta-minimal.zcml	                        (rev 0)
+++ grokcore.security/trunk/src/grokcore/security/meta-minimal.zcml	2012-04-30 15:41:12 UTC (rev 125448)
@@ -0,0 +1,6 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:grok="http://namespaces.zope.org/grok">
+  <include package="grokcore.component" file="meta.zcml" />
+  <grok:grok package=".meta.permission" />
+</configure>

Deleted: grokcore.security/trunk/src/grokcore/security/meta.py
===================================================================
--- grokcore.security/trunk/src/grokcore/security/meta.py	2012-04-30 14:50:30 UTC (rev 125447)
+++ grokcore.security/trunk/src/grokcore/security/meta.py	2012-04-30 15:41:12 UTC (rev 125448)
@@ -1,105 +0,0 @@
-#############################################################################
-#
-# Copyright (c) 2006-2007 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Grokkers for security-related components."""
-
-import martian
-import grokcore.component
-import grokcore.component.util
-import grokcore.security
-
-from zope.security.interfaces import IPermission
-from martian.error import GrokError
-
-
-def default_fallback_to_name(factory, module, name, **data):
-    return name
-
-class PermissionGrokker(martian.ClassGrokker):
-    martian.component(grokcore.security.Permission)
-    martian.priority(1500)
-    martian.directive(grokcore.component.name)
-    martian.directive(grokcore.component.title,
-                      get_default=default_fallback_to_name)
-    martian.directive(grokcore.component.description)
-
-    def execute(self, factory, config, name, title, description, **kw):
-        if not name:
-            raise GrokError(
-                "A permission needs to have a dotted name for its id. Use "
-                "grok.name to specify one.", factory)
-        # We can safely convert to unicode, since the directives make sure
-        # it is either unicode already or ASCII.
-        permission = factory(unicode(name), unicode(title),
-                             unicode(description))
-
-        config.action(
-            discriminator=('utility', IPermission, name),
-            callable=grokcore.component.util.provideUtility,
-            args=(permission, IPermission, name),
-            order=-1 # need to do this early in the process
-            )
-        return True
-
-
-from zope.i18nmessageid import Message
-from zope.securitypolicy.rolepermission import rolePermissionManager
-from zope.securitypolicy.interfaces import IRole
-
-from grokcore.security.directive import permissions
-from grokcore.security.components import Role
-
-
-class RoleGrokker(martian.ClassGrokker):
-    """Grokker for components subclassed from `grok.Role`.
-
-    Each role is registered as a global utility providing the service
-    `IRole` under its own particular name, and then granted every
-    permission named in its `grok.permission()` directive.
-
-    """
-    martian.component(Role)
-    martian.priority(martian.priority.bind().get(PermissionGrokker()) - 1)
-    martian.directive(grokcore.component.name)
-    martian.directive(
-        grokcore.component.title, get_default=default_fallback_to_name)
-    martian.directive(grokcore.component.description)
-    martian.directive(permissions)
-
-    def execute(self, factory, config, name, title, description,
-                permissions, **kw):
-        if not name:
-            raise GrokError(
-                "A role needs to have a dotted name for its id. Use "
-                "grok.name to specify one.", factory)
-        # We can safely convert to unicode, since the directives makes sure
-        # it is either unicode already or ASCII.
-        if not isinstance(title, Message):
-            title = unicode(title)
-        if not isinstance(description, Message):
-            description = unicode(description)
-        role = factory(unicode(name), title, description)
-
-        config.action(
-            discriminator=('utility', IRole, name),
-            callable=grokcore.component.util.provideUtility,
-            args=(role, IRole, name),
-            )
-
-        for permission in permissions:
-            config.action(
-                discriminator=('grantPermissionToRole', permission, name),
-                callable=rolePermissionManager.grantPermissionToRole,
-                args=(permission, name),
-                )
-        return True
\ No newline at end of file

Modified: grokcore.security/trunk/src/grokcore/security/meta.zcml
===================================================================
--- grokcore.security/trunk/src/grokcore/security/meta.zcml	2012-04-30 14:50:30 UTC (rev 125447)
+++ grokcore.security/trunk/src/grokcore/security/meta.zcml	2012-04-30 15:41:12 UTC (rev 125448)
@@ -1,9 +1,7 @@
 <configure
     xmlns="http://namespaces.zope.org/zope"
     xmlns:grok="http://namespaces.zope.org/grok">
-
-  <!-- Load the grokkers -->
   <include package="grokcore.component" file="meta.zcml" />
-  <grok:grok package=".meta" />
-
+  <grok:grok package=".meta.permission" />
+  <grok:grok package=".meta.role" />
 </configure>



More information about the checkins mailing list