[Checkins] SVN: z3ext.permissionsmap/tags/1.3.0/ release tag
Nikolay Kim
fafhrd91 at gmail.com
Tue Aug 11 06:35:58 EDT 2009
Log message for revision 102671:
release tag
Changed:
A z3ext.permissionsmap/tags/1.3.0/
D z3ext.permissionsmap/tags/1.3.0/CHANGES.txt
A z3ext.permissionsmap/tags/1.3.0/CHANGES.txt
D z3ext.permissionsmap/tags/1.3.0/bootstrap.py
A z3ext.permissionsmap/tags/1.3.0/bootstrap.py
D z3ext.permissionsmap/tags/1.3.0/setup.py
A z3ext.permissionsmap/tags/1.3.0/setup.py
D z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/interfaces.py
A z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/interfaces.py
D z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/manager.py
A z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/manager.py
D z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/permissionsmap.py
A z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/permissionsmap.py
D z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/support.py
A z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/support.py
D z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/tests.py
A z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/tests.py
D z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/zcml.py
A z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/zcml.py
-=-
Deleted: z3ext.permissionsmap/tags/1.3.0/CHANGES.txt
===================================================================
--- z3ext.permissionsmap/trunk/CHANGES.txt 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/CHANGES.txt 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,61 +0,0 @@
-=======
-CHANGES
-=======
-
-1.2.3 (Unreleased)
-------------------
-
-- Do not register named utility for default content permissions
-
-
-1.2.2 (2009-04-30)
-------------------
-
-- Better discriminator for zcml directive
-
-
-1.2.1 (2009-03-12)
-------------------
-
-- Calculate roles settings dynamicly for <denyAll> and <grantAll>
- (Check for local roles)
-
-
-1.2.0 (2008-03-21)
-------------------
-
-- Move code to svn.zope.org
-
-
-1.1.2 (2008-03-19)
-------------------
-
-- 100% tests coverage
-
-- Code cleanup
-
-- Minor performance seepdup
-
-
-1.1.1 (2008-02-16)
-------------------
-
-- Performance (profiling)
-
-
-1.1.0 (2008-01-31)
-------------------
-
-- Fixed: Do not use IRolePermissionMap as base interface
- because z3ext.security policy use object permission map
- and PermissionsManManager at the same time
-
-- Added license information
-
-- Fixed rest format in README.txt
-
-
-1.0.0 (2007-12-08)
-------------------
-
-- Initial release.
Copied: z3ext.permissionsmap/tags/1.3.0/CHANGES.txt (from rev 102668, z3ext.permissionsmap/trunk/CHANGES.txt)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/CHANGES.txt (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/CHANGES.txt 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,63 @@
+=======
+CHANGES
+=======
+
+1.3.0 (2009-08-11)
+------------------
+
+- Do not register named utility for default content permissions
+
+- Copyright holder changed
+
+
+1.2.2 (2009-04-30)
+------------------
+
+- Better discriminator for zcml directive
+
+
+1.2.1 (2009-03-12)
+------------------
+
+- Calculate roles settings dynamicly for <denyAll> and <grantAll>
+ (Check for local roles)
+
+
+1.2.0 (2008-03-21)
+------------------
+
+- Move code to svn.zope.org
+
+
+1.1.2 (2008-03-19)
+------------------
+
+- 100% tests coverage
+
+- Code cleanup
+
+- Minor performance seepdup
+
+
+1.1.1 (2008-02-16)
+------------------
+
+- Performance (profiling)
+
+
+1.1.0 (2008-01-31)
+------------------
+
+- Fixed: Do not use IRolePermissionMap as base interface
+ because z3ext.security policy use object permission map
+ and PermissionsManManager at the same time
+
+- Added license information
+
+- Fixed rest format in README.txt
+
+
+1.0.0 (2007-12-08)
+------------------
+
+- Initial release.
Deleted: z3ext.permissionsmap/tags/1.3.0/bootstrap.py
===================================================================
--- z3ext.permissionsmap/trunk/bootstrap.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/bootstrap.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 Zope Corporation 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.
-#
-##############################################################################
-"""Bootstrap a buildout-based project
-
-Simply run this script in a directory containing a buildout.cfg.
-The script accepts buildout command-line options, so you can
-use the -c option to specify an alternate configuration file.
-
-$Id$
-"""
-
-import os, shutil, sys, tempfile, urllib2
-
-tmpeggs = tempfile.mkdtemp()
-
-ez = {}
-exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
- ).read() in ez
-ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
-
-import pkg_resources
-
-cmd = 'from setuptools.command.easy_install import main; main()'
-if sys.platform == 'win32':
- cmd = '"%s"' % cmd # work around spawn lamosity on windows
-
-ws = pkg_resources.working_set
-assert os.spawnle(
- os.P_WAIT, sys.executable, sys.executable,
- '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
- dict(os.environ,
- PYTHONPATH=
- ws.find(pkg_resources.Requirement.parse('setuptools')).location
- ),
- ) == 0
-
-ws.add_entry(tmpeggs)
-ws.require('zc.buildout')
-import zc.buildout.buildout
-zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
-shutil.rmtree(tmpeggs)
Copied: z3ext.permissionsmap/tags/1.3.0/bootstrap.py (from rev 102668, z3ext.permissionsmap/trunk/bootstrap.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/bootstrap.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/bootstrap.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Deleted: z3ext.permissionsmap/tags/1.3.0/setup.py
===================================================================
--- z3ext.permissionsmap/trunk/setup.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/setup.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,72 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation 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.
-#
-##############################################################################
-"""Setup for z3ext.permissionsmap package
-
-$Id$
-"""
-import sys, os
-from setuptools import setup, find_packages
-
-def read(*rnames):
- return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
-version = '1.2.3dev'
-
-
-setup(name='z3ext.permissionsmap',
- version=version,
- description="Permissions maps for Zope3",
- long_description=(
- 'Detailed Documentation\n' +
- '======================\n'
- + '\n\n' +
- read('src', 'z3ext', 'permissionsmap', 'README.txt')
- + '\n\n' +
- read('CHANGES.txt')
- ),
- classifiers=[
- 'Development Status :: 5 - Production/Stable',
- 'Environment :: Web Environment',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: Zope Public License',
- 'Programming Language :: Python',
- 'Natural Language :: English',
- 'Operating System :: OS Independent',
- 'Topic :: Internet :: WWW/HTTP',
- 'Framework :: Zope3'],
- author='Nikolay Kim',
- author_email='fafhrd91 at gmail.com',
- url='http://z3ext.net/',
- license='ZPL 2.1',
- packages=find_packages('src'),
- package_dir = {'':'src'},
- namespace_packages=['z3ext'],
- install_requires = ['setuptools',
- 'zope.event',
- 'zope.schema',
- 'zope.interface',
- 'zope.component',
- 'zope.location',
- 'zope.annotation',
- 'zope.security',
- 'zope.securitypolicy',
- 'zope.configuration',
- 'z3ext.security',
- ],
- extras_require = dict(test=['zope.app.testing',
- 'zope.testing',
- ]),
- include_package_data = True,
- zip_safe = False
- )
Copied: z3ext.permissionsmap/tags/1.3.0/setup.py (from rev 102668, z3ext.permissionsmap/trunk/setup.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/setup.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/setup.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,72 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+"""Setup for z3ext.permissionsmap package
+
+$Id$
+"""
+import sys, os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+version = '1.3.0'
+
+
+setup(name='z3ext.permissionsmap',
+ version=version,
+ description="Permissions maps for Zope3",
+ long_description=(
+ 'Detailed Documentation\n' +
+ '======================\n'
+ + '\n\n' +
+ read('src', 'z3ext', 'permissionsmap', 'README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ classifiers=[
+ 'Development Status :: 5 - Production/Stable',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ author='Nikolay Kim',
+ author_email='fafhrd91 at gmail.com',
+ url='http://z3ext.net/',
+ license='ZPL 2.1',
+ packages=find_packages('src'),
+ package_dir = {'':'src'},
+ namespace_packages=['z3ext'],
+ install_requires = ['setuptools',
+ 'zope.event',
+ 'zope.schema',
+ 'zope.interface',
+ 'zope.component',
+ 'zope.location',
+ 'zope.annotation',
+ 'zope.security',
+ 'zope.securitypolicy',
+ 'zope.configuration',
+ 'z3ext.security',
+ ],
+ extras_require = dict(test=['zope.app.testing',
+ 'zope.testing',
+ ]),
+ include_package_data = True,
+ zip_safe = False
+ )
Deleted: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/interfaces.py
===================================================================
--- z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/interfaces.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/interfaces.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,72 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation 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.
-#
-##############################################################################
-""" z3ext.permissionsmap interfaces
-
-$Id$
-"""
-from zope import schema, interface
-from zope.component.interfaces import IObjectEvent
-
-
-class UnknownPermissionsMap(Exception):
- """ Unknown permissions map """
-
-
-class IPermissionsMap(interface.Interface):
- """ named IRolePermissionMap object """
-
- name = schema.TextLine(
- title=u"Name",
- description=u"Permissions map identifier.",
- required=True)
-
- title = schema.TextLine(
- title=u"Title",
- description=u"Permissions map title.",
- required=True)
-
- description = schema.TextLine(
- title=u"Description",
- description=u"Permissions map description.",
- required=False)
-
-
-class IDefaultPermissionsMap(interface.Interface):
- """ marker interface for default class/interface permissions map """
-
-
-class IObjectPermissionsMaps(interface.Interface):
-
- def get():
- """ return object permissions maps """
-
-
-class IObjectPermissionsMapsManager(interface.Interface):
-
- def set(maps):
- """ set object permissions maps """
-
-
-class IObjectPermissionsMapsModifiedEvent(IObjectEvent):
- """ object permissions maps modified """
-
- maps = interface.Attribute('Mew maps list')
-
-
-class ObjectPermissionsMapsModifiedEvent(object):
- interface.implements(IObjectPermissionsMapsModifiedEvent)
-
- def __init__(self, object, maps):
- self.object = object
- self.maps = maps
Copied: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/interfaces.py (from rev 102668, z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/interfaces.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/interfaces.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/interfaces.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,72 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+""" z3ext.permissionsmap interfaces
+
+$Id$
+"""
+from zope import schema, interface
+from zope.component.interfaces import IObjectEvent
+
+
+class UnknownPermissionsMap(Exception):
+ """ Unknown permissions map """
+
+
+class IPermissionsMap(interface.Interface):
+ """ named IRolePermissionMap object """
+
+ name = schema.TextLine(
+ title=u"Name",
+ description=u"Permissions map identifier.",
+ required=True)
+
+ title = schema.TextLine(
+ title=u"Title",
+ description=u"Permissions map title.",
+ required=True)
+
+ description = schema.TextLine(
+ title=u"Description",
+ description=u"Permissions map description.",
+ required=False)
+
+
+class IDefaultPermissionsMap(interface.Interface):
+ """ marker interface for default class/interface permissions map """
+
+
+class IObjectPermissionsMaps(interface.Interface):
+
+ def get():
+ """ return object permissions maps """
+
+
+class IObjectPermissionsMapsManager(interface.Interface):
+
+ def set(maps):
+ """ set object permissions maps """
+
+
+class IObjectPermissionsMapsModifiedEvent(IObjectEvent):
+ """ object permissions maps modified """
+
+ maps = interface.Attribute('Mew maps list')
+
+
+class ObjectPermissionsMapsModifiedEvent(object):
+ interface.implements(IObjectPermissionsMapsModifiedEvent)
+
+ def __init__(self, object, maps):
+ self.object = object
+ self.maps = maps
Deleted: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/manager.py
===================================================================
--- z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/manager.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/manager.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,67 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface, component
-from zope.component import getAdapters
-from zope.location.interfaces import ILocation
-from zope.securitypolicy.interfaces import IRolePermissionMap
-
-from interfaces import IPermissionsMap, IObjectPermissionsMaps
-
-
-class PermissionsMapManager(object):
- component.adapts(ILocation)
- interface.implements(IRolePermissionMap)
-
- def __init__(self, context):
- perms = []
-
- # first get object permissionsmap
- supp = IObjectPermissionsMaps(context, None)
- if supp is not None:
- perms.extend(supp.get())
-
- # then get adapted permissionsmap
- for name, permissions in getAdapters((context,), IPermissionsMap):
- perms.append(permissions)
-
- self.perms = perms
-
- def getPermissionsForRole(self, role_id):
- permissions = {}
- for perm in self.perms:
- for permission, setting in perm.getPermissionsForRole(role_id):
- if permission not in permissions:
- permissions[permission] = setting
-
- return permissions.items()
-
- def getRolesForPermission(self, permission_id):
- """ check permissions in order """
- roles = {}
- for perm in self.perms:
- for role, setting in perm.getRolesForPermission(permission_id):
- if role not in roles:
- roles[role] = setting
-
- return roles.items()
-
- def getSetting(self, permission_id, role_id):
- return ()
-
- def getRolesAndPermissions(self):
- return ()
Copied: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/manager.py (from rev 102668, z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/manager.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/manager.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/manager.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope import interface, component
+from zope.component import getAdapters
+from zope.location.interfaces import ILocation
+from zope.securitypolicy.interfaces import IRolePermissionMap
+
+from interfaces import IPermissionsMap, IObjectPermissionsMaps
+
+
+class PermissionsMapManager(object):
+ component.adapts(ILocation)
+ interface.implements(IRolePermissionMap)
+
+ def __init__(self, context):
+ perms = []
+
+ # first get object permissionsmap
+ supp = IObjectPermissionsMaps(context, None)
+ if supp is not None:
+ perms.extend(supp.get())
+
+ # then get adapted permissionsmap
+ for name, permissions in getAdapters((context,), IPermissionsMap):
+ perms.append(permissions)
+
+ self.perms = perms
+
+ def getPermissionsForRole(self, role_id):
+ permissions = {}
+ for perm in self.perms:
+ for permission, setting in perm.getPermissionsForRole(role_id):
+ if permission not in permissions:
+ permissions[permission] = setting
+
+ return permissions.items()
+
+ def getRolesForPermission(self, permission_id):
+ """ check permissions in order """
+ roles = {}
+ for perm in self.perms:
+ for role, setting in perm.getRolesForPermission(permission_id):
+ if role not in roles:
+ roles[role] = setting
+
+ return roles.items()
+
+ def getSetting(self, permission_id, role_id):
+ return ()
+
+ def getRolesAndPermissions(self):
+ return ()
Deleted: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/permissionsmap.py
===================================================================
--- z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/permissionsmap.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/permissionsmap.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,82 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface
-from zope.component import getUtilitiesFor
-from zope.securitypolicy.interfaces import IRole
-from zope.securitypolicy.interfaces import Allow, Deny, Unset
-from zope.securitypolicy.securitymap import PersistentSecurityMap
-from zope.securitypolicy.rolepermission import RolePermissionManager
-
-from interfaces import IPermissionsMap
-
-
-class PermissionsMap(PersistentSecurityMap, RolePermissionManager):
- interface.implements(IPermissionsMap)
-
- def __init__(self, name, title, description=''):
- super(PermissionsMap, self).__init__()
- self.name = name
- self.title = title
- self.description = description
-
- self.denyall = []
- self.grantall = []
-
- def __repr__(self):
- return 'PermissionsMap(%r)' % self.name
-
- def getPermissionsForRole(self, role_id):
- settings = {}
-
- if self.grantall:
- settings.update(
- [(pid, Allow) for pid in self.grantall])
-
- if self.denyall:
- settings.update(
- [(pid, Deny) for pid in self.denyall])
-
- if settings:
- settings.update(
- [(pid, setting) for pid, setting in \
- super(PermissionsMap, self).getPermissionsForRole(role_id)])
-
- return settings.items()
-
- else:
- return super(PermissionsMap, self).getPermissionsForRole(role_id)
-
- def getRolesForPermission(self, permission_id):
- all = None
-
- if permission_id in self.denyall:
- all = Deny
- elif permission_id in self.grantall:
- all = Allow
-
- if all is not None:
- settings = dict(
- [(id, all) for id, role in getUtilitiesFor(IRole)])
-
- settings.update(
- [(rid, setting) for rid, setting in \
- super(PermissionsMap, self).getRolesForPermission(permission_id)])
-
- return settings.items()
- else:
- return super(PermissionsMap, self).getRolesForPermission(permission_id)
Copied: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/permissionsmap.py (from rev 102668, z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/permissionsmap.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/permissionsmap.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/permissionsmap.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope import interface
+from zope.component import getUtilitiesFor
+from zope.securitypolicy.interfaces import IRole
+from zope.securitypolicy.interfaces import Allow, Deny, Unset
+from zope.securitypolicy.securitymap import PersistentSecurityMap
+from zope.securitypolicy.rolepermission import RolePermissionManager
+
+from interfaces import IPermissionsMap
+
+
+class PermissionsMap(PersistentSecurityMap, RolePermissionManager):
+ interface.implements(IPermissionsMap)
+
+ def __init__(self, name, title, description=''):
+ super(PermissionsMap, self).__init__()
+ self.name = name
+ self.title = title
+ self.description = description
+
+ self.denyall = []
+ self.grantall = []
+
+ def __repr__(self):
+ return 'PermissionsMap(%r)' % self.name
+
+ def getPermissionsForRole(self, role_id):
+ settings = {}
+
+ if self.grantall:
+ settings.update(
+ [(pid, Allow) for pid in self.grantall])
+
+ if self.denyall:
+ settings.update(
+ [(pid, Deny) for pid in self.denyall])
+
+ if settings:
+ settings.update(
+ [(pid, setting) for pid, setting in \
+ super(PermissionsMap, self).getPermissionsForRole(role_id)])
+
+ return settings.items()
+
+ else:
+ return super(PermissionsMap, self).getPermissionsForRole(role_id)
+
+ def getRolesForPermission(self, permission_id):
+ all = None
+
+ if permission_id in self.denyall:
+ all = Deny
+ elif permission_id in self.grantall:
+ all = Allow
+
+ if all is not None:
+ settings = dict(
+ [(id, all) for id, role in getUtilitiesFor(IRole)])
+
+ settings.update(
+ [(rid, setting) for rid, setting in \
+ super(PermissionsMap, self).getRolesForPermission(permission_id)])
+
+ return settings.items()
+ else:
+ return super(PermissionsMap, self).getRolesForPermission(permission_id)
Deleted: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/support.py
===================================================================
--- z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/support.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/support.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,68 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import event, interface, component
-from zope.component import queryUtility
-from zope.annotation.interfaces import IAnnotations, IAnnotatable
-
-from interfaces import UnknownPermissionsMap
-from interfaces import IPermissionsMap, ObjectPermissionsMapsModifiedEvent
-from interfaces import IObjectPermissionsMaps, IObjectPermissionsMapsManager
-
-KEY = 'z3ext.permissionsmap'
-
-
-class ObjectPermissionsMaps(object):
- component.adapts(IAnnotatable)
- interface.implements(IObjectPermissionsMaps)
-
- def __init__(self, context):
- annotations = IAnnotations(context)
- self.data = annotations.get(KEY, ())
-
- def get(self):
- perms = []
- for name in self.data:
- perm = queryUtility(IPermissionsMap, name=name)
- if perm is not None:
- yield perm
-
-
-class ObjectPermissionsMapsManager(object):
- component.adapts(IAnnotatable)
- interface.implements(IObjectPermissionsMapsManager)
-
- def __init__(self, context):
- self.context = context
- self.annotations = IAnnotations(context)
- self.data = self.annotations.get(KEY, ())
-
- def set(self, perms):
- for name in perms:
- perm = queryUtility(IPermissionsMap, name=name)
- if perm is None:
- raise UnknownPermissionsMap(
- "Undefined permissions map id", name)
-
- if perms:
- self.data = tuple(perms)
- self.annotations[KEY] = self.data
- else:
- if KEY in self.annotations:
- del self.annotations[KEY]
-
- event.notify(ObjectPermissionsMapsModifiedEvent(self.context, self.data))
Copied: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/support.py (from rev 102668, z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/support.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/support.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/support.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope import event, interface, component
+from zope.component import queryUtility
+from zope.annotation.interfaces import IAnnotations, IAnnotatable
+
+from interfaces import UnknownPermissionsMap
+from interfaces import IPermissionsMap, ObjectPermissionsMapsModifiedEvent
+from interfaces import IObjectPermissionsMaps, IObjectPermissionsMapsManager
+
+KEY = 'z3ext.permissionsmap'
+
+
+class ObjectPermissionsMaps(object):
+ component.adapts(IAnnotatable)
+ interface.implements(IObjectPermissionsMaps)
+
+ def __init__(self, context):
+ annotations = IAnnotations(context)
+ self.data = annotations.get(KEY, ())
+
+ def get(self):
+ perms = []
+ for name in self.data:
+ perm = queryUtility(IPermissionsMap, name=name)
+ if perm is not None:
+ yield perm
+
+
+class ObjectPermissionsMapsManager(object):
+ component.adapts(IAnnotatable)
+ interface.implements(IObjectPermissionsMapsManager)
+
+ def __init__(self, context):
+ self.context = context
+ self.annotations = IAnnotations(context)
+ self.data = self.annotations.get(KEY, ())
+
+ def set(self, perms):
+ for name in perms:
+ perm = queryUtility(IPermissionsMap, name=name)
+ if perm is None:
+ raise UnknownPermissionsMap(
+ "Undefined permissions map id", name)
+
+ if perms:
+ self.data = tuple(perms)
+ self.annotations[KEY] = self.data
+ else:
+ if KEY in self.annotations:
+ del self.annotations[KEY]
+
+ event.notify(ObjectPermissionsMapsModifiedEvent(self.context, self.data))
Deleted: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/tests.py
===================================================================
--- z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/tests.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/tests.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,82 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation 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.
-#
-##############################################################################
-""" z3ext.permissionsmap tests
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import unittest, doctest
-from zope import interface
-from zope.component import provideAdapter, provideUtility
-from zope.app.testing import setup
-
-from zope.securitypolicy.role import Role
-from zope.security.permission import Permission
-from zope.annotation.attribute import AttributeAnnotations
-
-from manager import PermissionsMapManager
-from support import ObjectPermissionsMaps, ObjectPermissionsMapsManager
-
-
-r1 = Role('r1', 'Role1')
-r2 = Role('r2', 'Role2')
-r3 = Role('r3', 'Role3')
-
-p1 = Permission('my.p1')
-p2 = Permission('my.p2')
-p3 = Permission('my.p3')
-
-
-class ITestContent1(interface.Interface):
- pass
-
-class ITestContent2(interface.Interface):
- pass
-
-class TestContent1(object):
- interface.implements(ITestContent1)
-
-class TestContent2(object):
- interface.implements(ITestContent2)
-
-
-def setUp(test):
- setup.placelessSetUp()
-
- provideUtility(r1, name='r1')
- provideUtility(r2, name='r2')
- provideUtility(r3, name='r3')
-
- provideUtility(p1, name='my.p1')
- provideUtility(p2, name='my.p2')
- provideUtility(p3, name='my.p3')
-
- provideAdapter(AttributeAnnotations)
- provideAdapter(ObjectPermissionsMaps)
- provideAdapter(ObjectPermissionsMapsManager)
- provideAdapter(PermissionsMapManager,
- (interface.Interface,), name='z3ext.permissionsmap')
-
-def tearDown(test):
- setup.placelessTearDown()
-
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite(
- 'README.txt',
- setUp=setUp, tearDown=tearDown,
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
- ))
Copied: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/tests.py (from rev 102668, z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/tests.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/tests.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/tests.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+""" z3ext.permissionsmap tests
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest, doctest
+from zope import interface
+from zope.component import provideAdapter, provideUtility
+from zope.app.testing import setup
+
+from zope.securitypolicy.role import Role
+from zope.security.permission import Permission
+from zope.annotation.attribute import AttributeAnnotations
+
+from manager import PermissionsMapManager
+from support import ObjectPermissionsMaps, ObjectPermissionsMapsManager
+
+
+r1 = Role('r1', 'Role1')
+r2 = Role('r2', 'Role2')
+r3 = Role('r3', 'Role3')
+
+p1 = Permission('my.p1')
+p2 = Permission('my.p2')
+p3 = Permission('my.p3')
+
+
+class ITestContent1(interface.Interface):
+ pass
+
+class ITestContent2(interface.Interface):
+ pass
+
+class TestContent1(object):
+ interface.implements(ITestContent1)
+
+class TestContent2(object):
+ interface.implements(ITestContent2)
+
+
+def setUp(test):
+ setup.placelessSetUp()
+
+ provideUtility(r1, name='r1')
+ provideUtility(r2, name='r2')
+ provideUtility(r3, name='r3')
+
+ provideUtility(p1, name='my.p1')
+ provideUtility(p2, name='my.p2')
+ provideUtility(p3, name='my.p3')
+
+ provideAdapter(AttributeAnnotations)
+ provideAdapter(ObjectPermissionsMaps)
+ provideAdapter(ObjectPermissionsMapsManager)
+ provideAdapter(PermissionsMapManager,
+ (interface.Interface,), name='z3ext.permissionsmap')
+
+def tearDown(test):
+ setup.placelessTearDown()
+
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ ))
Deleted: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/zcml.py
===================================================================
--- z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/zcml.py 2009-08-10 15:09:13 UTC (rev 102629)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/zcml.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -1,277 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation 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.
-#
-##############################################################################
-""" zcml directive
-
-$Id$
-"""
-from zope.component import globalregistry
-from zope.component import getUtility, queryUtility, getUtilitiesFor
-
-from zope import schema, interface, component
-from zope.security.zcml import Permission
-from zope.configuration.fields import Tokens, GlobalObject
-from zope.securitypolicy.interfaces import IRole
-
-from interfaces import IPermissionsMap
-from interfaces import IDefaultPermissionsMap
-from permissionsmap import PermissionsMap
-
-
-class IPermissionsMapDirective(interface.Interface):
- """ define permissions map directive"""
-
- name = schema.TextLine(
- title=u"Name",
- description=u"Permissions map identifier.",
- required=True)
-
- for_ = GlobalObject(
- title=u"For",
- required=False)
-
- title = schema.TextLine(
- title=u"Title",
- description=u"Permissions map title.",
- required=False)
-
- description = schema.TextLine(
- title=u"Description",
- description=u"Permissions map description.",
- required=False)
-
- override = schema.Bool(
- title=u"Override",
- description=u"Allow override sub directives for this declaration.",
- required=False,
- default=True)
-
-
-class IGrantDirective(interface.Interface):
-
- role = Tokens(
- title=u"Role",
- description=u"Specifies the role.",
- required=True,
- value_type=schema.TextLine())
-
- permission = Tokens(
- title=u"Permission",
- description=u"Specifies the permission to be mapped.",
- required=True,
- value_type=Permission())
-
-
-class IDenyDirective(interface.Interface):
-
- role = Tokens(
- title=u"Role",
- description=u"Specifies the role.",
- required=True,
- value_type=schema.TextLine())
-
- permission = Tokens(
- title=u"Permission",
- description=u"Specifies the permission to be mapped.",
- required=True,
- value_type=Permission())
-
-
-class IUnsetDirective(interface.Interface):
-
- role = Tokens(
- title=u"Role",
- description=u"Specifies the role.",
- required=True,
- value_type=schema.TextLine())
-
- permission = Tokens(
- title=u"Permission",
- description=u"Specifies the permission to be mapped.",
- required=True,
- value_type=Permission())
-
-
-class IGrantAllDirective(interface.Interface):
-
- permission = Tokens(
- title=u"Permission",
- description=u"Specifies the permission to be mapped.",
- required=True,
- value_type=Permission())
-
-
-class IDenyAllDirective(interface.Interface):
-
- permission = Tokens(
- title=u"Permission",
- description=u"Specifies the permission to be mapped.",
- required=True,
- value_type=Permission())
-
-
-class IUnsetAllDirective(interface.Interface):
-
- permission = Tokens(
- title=u"Permission",
- description=u"Specifies the permission to be mapped.",
- required=True,
- value_type=Permission())
-
-
-class ClassPermissionsFactory(object):
-
- def __init__(self, permissionsmap):
- self.permissionsmap = permissionsmap
-
- def __call__(self, context):
- return self.permissionsmap
-
-classPermissions = {}
-
-
-def permissionsHandler(name, for_, title, description):
- # check if map already exists
- sm = globalregistry.globalSiteManager
-
- if for_ is not None:
- global classPermissions
-
- perms = classPermissions.get(for_)
- if perms is not None:
- return
-
- perms = PermissionsMap(name, title, description)
- classPermissions[for_] = perms
- interface.alsoProvides(perms, IDefaultPermissionsMap)
-
- # register map as adapter for for_
- factory = ClassPermissionsFactory(perms)
- sm.registerAdapter(factory, (for_,), IPermissionsMap, name)
-
- else:
- perms = sm.queryUtility(IPermissionsMap, name)
- if perms is not None:
- return
-
- # register map as utility
- perms = PermissionsMap(name, title, description)
- sm.registerUtility(perms, IPermissionsMap, name)
-
-
-def directiveHandler(name, method, permissions, roles, for_=None, check=False):
- sm = globalregistry.globalSiteManager
-
- if for_ is not None:
- permissionmap = classPermissions[for_]
- else:
- permissionmap = sm.getUtility(IPermissionsMap, name)
-
- for role in roles:
- for permission in permissions:
- if not check:
- getattr(permissionmap, method)(permission, role, False)
- else:
- getattr(permissionmap, method)(permission, role)
-
-
-def directiveHandlerAll(name, method, permissions, attr, for_=None):
- sm = globalregistry.globalSiteManager
-
- if for_ is not None:
- permissionmap = classPermissions[for_]
- else:
- permissionmap = sm.getUtility(IPermissionsMap, name)
-
- if attr == 'unsetall':
- for role_id, role in getUtilitiesFor(IRole):
- for permission in permissions:
- getattr(permissionmap, method)(permission, role_id)
- else:
- lst = getattr(permissionmap, attr)
- for permission in permissions:
- if permission not in lst:
- lst.append(permission)
-
-
-class permissionsMapDirective(object):
-
- def __init__(self, _context, name, for_=None,
- title='', description='', override=True):
- self.for_ = for_
- self.name = name
- self.override = override
-
- _context.action(
- discriminator = self.discriminator(('z3ext.permissions', name)),
- callable = permissionsHandler,
- args = (name, for_, title, description))
-
- def discriminator(self, data):
- if self.override:
- data = data + (object(),)
- return data
-
- def grant(self, _context, role, permission):
- _context.action(
- discriminator = self.discriminator(
- ('z3ext.permissions.grant',
- self.name, self.for_, tuple(role), tuple(permission))),
- callable = directiveHandler,
- args = (self.name, 'grantPermissionToRole',
- permission, role, self.for_))
-
- def deny(self, _context, role, permission):
- _context.action(
- discriminator = self.discriminator(
- ('z3ext.permissions.deny',
- self.name, self.for_, tuple(role), tuple(permission))),
- callable = directiveHandler,
- args = (self.name, 'denyPermissionToRole',
- permission, role, self.for_))
-
- def unset(self, _context, role, permission):
- _context.action(
- discriminator = self.discriminator(
- ('z3ext.permissions.unset',
- self.name, self.for_, tuple(role), tuple(permission))),
- callable = directiveHandler,
- args = (self.name, 'unsetPermissionFromRole',
- permission, role, self.for_, True))
-
- def grantAll(self, _context, permission):
- _context.action(
- discriminator = self.discriminator(
- ('z3ext.permissions.grantAll',
- self.name, self.for_, tuple(permission))),
- callable = directiveHandlerAll,
- args = (self.name, 'grantPermissionToRole',
- permission, 'grantall', self.for_))
-
- def denyAll(self, _context, permission):
- _context.action(
- discriminator = self.discriminator(
- ('z3ext.permissions.denyAll',
- self.name, self.for_, tuple(permission))),
- callable = directiveHandlerAll,
- args = (self.name, 'denyPermissionToRole',
- permission, 'denyall', self.for_))
-
- def unsetAll(self, _context, permission):
- _context.action(
- discriminator = self.discriminator(
- ('z3ext.permissions.unsetAll',
- self.name, self.for_, tuple(permission))),
- callable = directiveHandlerAll,
- args = (self.name, 'unsetPermissionFromRole',
- permission, 'unsetall', self.for_))
Copied: z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/zcml.py (from rev 102668, z3ext.permissionsmap/trunk/src/z3ext/permissionsmap/zcml.py)
===================================================================
--- z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/zcml.py (rev 0)
+++ z3ext.permissionsmap/tags/1.3.0/src/z3ext/permissionsmap/zcml.py 2009-08-11 10:35:57 UTC (rev 102671)
@@ -0,0 +1,277 @@
+##############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+""" zcml directive
+
+$Id$
+"""
+from zope.component import globalregistry
+from zope.component import getUtility, queryUtility, getUtilitiesFor
+
+from zope import schema, interface, component
+from zope.security.zcml import Permission
+from zope.configuration.fields import Tokens, GlobalObject
+from zope.securitypolicy.interfaces import IRole
+
+from interfaces import IPermissionsMap
+from interfaces import IDefaultPermissionsMap
+from permissionsmap import PermissionsMap
+
+
+class IPermissionsMapDirective(interface.Interface):
+ """ define permissions map directive"""
+
+ name = schema.TextLine(
+ title=u"Name",
+ description=u"Permissions map identifier.",
+ required=True)
+
+ for_ = GlobalObject(
+ title=u"For",
+ required=False)
+
+ title = schema.TextLine(
+ title=u"Title",
+ description=u"Permissions map title.",
+ required=False)
+
+ description = schema.TextLine(
+ title=u"Description",
+ description=u"Permissions map description.",
+ required=False)
+
+ override = schema.Bool(
+ title=u"Override",
+ description=u"Allow override sub directives for this declaration.",
+ required=False,
+ default=True)
+
+
+class IGrantDirective(interface.Interface):
+
+ role = Tokens(
+ title=u"Role",
+ description=u"Specifies the role.",
+ required=True,
+ value_type=schema.TextLine())
+
+ permission = Tokens(
+ title=u"Permission",
+ description=u"Specifies the permission to be mapped.",
+ required=True,
+ value_type=Permission())
+
+
+class IDenyDirective(interface.Interface):
+
+ role = Tokens(
+ title=u"Role",
+ description=u"Specifies the role.",
+ required=True,
+ value_type=schema.TextLine())
+
+ permission = Tokens(
+ title=u"Permission",
+ description=u"Specifies the permission to be mapped.",
+ required=True,
+ value_type=Permission())
+
+
+class IUnsetDirective(interface.Interface):
+
+ role = Tokens(
+ title=u"Role",
+ description=u"Specifies the role.",
+ required=True,
+ value_type=schema.TextLine())
+
+ permission = Tokens(
+ title=u"Permission",
+ description=u"Specifies the permission to be mapped.",
+ required=True,
+ value_type=Permission())
+
+
+class IGrantAllDirective(interface.Interface):
+
+ permission = Tokens(
+ title=u"Permission",
+ description=u"Specifies the permission to be mapped.",
+ required=True,
+ value_type=Permission())
+
+
+class IDenyAllDirective(interface.Interface):
+
+ permission = Tokens(
+ title=u"Permission",
+ description=u"Specifies the permission to be mapped.",
+ required=True,
+ value_type=Permission())
+
+
+class IUnsetAllDirective(interface.Interface):
+
+ permission = Tokens(
+ title=u"Permission",
+ description=u"Specifies the permission to be mapped.",
+ required=True,
+ value_type=Permission())
+
+
+class ClassPermissionsFactory(object):
+
+ def __init__(self, permissionsmap):
+ self.permissionsmap = permissionsmap
+
+ def __call__(self, context):
+ return self.permissionsmap
+
+classPermissions = {}
+
+
+def permissionsHandler(name, for_, title, description):
+ # check if map already exists
+ sm = globalregistry.globalSiteManager
+
+ if for_ is not None:
+ global classPermissions
+
+ perms = classPermissions.get(for_)
+ if perms is not None:
+ return
+
+ perms = PermissionsMap(name, title, description)
+ classPermissions[for_] = perms
+ interface.alsoProvides(perms, IDefaultPermissionsMap)
+
+ # register map as adapter for for_
+ factory = ClassPermissionsFactory(perms)
+ sm.registerAdapter(factory, (for_,), IPermissionsMap, name)
+
+ else:
+ perms = sm.queryUtility(IPermissionsMap, name)
+ if perms is not None:
+ return
+
+ # register map as utility
+ perms = PermissionsMap(name, title, description)
+ sm.registerUtility(perms, IPermissionsMap, name)
+
+
+def directiveHandler(name, method, permissions, roles, for_=None, check=False):
+ sm = globalregistry.globalSiteManager
+
+ if for_ is not None:
+ permissionmap = classPermissions[for_]
+ else:
+ permissionmap = sm.getUtility(IPermissionsMap, name)
+
+ for role in roles:
+ for permission in permissions:
+ if not check:
+ getattr(permissionmap, method)(permission, role, False)
+ else:
+ getattr(permissionmap, method)(permission, role)
+
+
+def directiveHandlerAll(name, method, permissions, attr, for_=None):
+ sm = globalregistry.globalSiteManager
+
+ if for_ is not None:
+ permissionmap = classPermissions[for_]
+ else:
+ permissionmap = sm.getUtility(IPermissionsMap, name)
+
+ if attr == 'unsetall':
+ for role_id, role in getUtilitiesFor(IRole):
+ for permission in permissions:
+ getattr(permissionmap, method)(permission, role_id)
+ else:
+ lst = getattr(permissionmap, attr)
+ for permission in permissions:
+ if permission not in lst:
+ lst.append(permission)
+
+
+class permissionsMapDirective(object):
+
+ def __init__(self, _context, name, for_=None,
+ title='', description='', override=True):
+ self.for_ = for_
+ self.name = name
+ self.override = override
+
+ _context.action(
+ discriminator = self.discriminator(('z3ext.permissions', name)),
+ callable = permissionsHandler,
+ args = (name, for_, title, description))
+
+ def discriminator(self, data):
+ if self.override:
+ data = data + (object(),)
+ return data
+
+ def grant(self, _context, role, permission):
+ _context.action(
+ discriminator = self.discriminator(
+ ('z3ext.permissions.grant',
+ self.name, self.for_, tuple(role), tuple(permission))),
+ callable = directiveHandler,
+ args = (self.name, 'grantPermissionToRole',
+ permission, role, self.for_))
+
+ def deny(self, _context, role, permission):
+ _context.action(
+ discriminator = self.discriminator(
+ ('z3ext.permissions.deny',
+ self.name, self.for_, tuple(role), tuple(permission))),
+ callable = directiveHandler,
+ args = (self.name, 'denyPermissionToRole',
+ permission, role, self.for_))
+
+ def unset(self, _context, role, permission):
+ _context.action(
+ discriminator = self.discriminator(
+ ('z3ext.permissions.unset',
+ self.name, self.for_, tuple(role), tuple(permission))),
+ callable = directiveHandler,
+ args = (self.name, 'unsetPermissionFromRole',
+ permission, role, self.for_, True))
+
+ def grantAll(self, _context, permission):
+ _context.action(
+ discriminator = self.discriminator(
+ ('z3ext.permissions.grantAll',
+ self.name, self.for_, tuple(permission))),
+ callable = directiveHandlerAll,
+ args = (self.name, 'grantPermissionToRole',
+ permission, 'grantall', self.for_))
+
+ def denyAll(self, _context, permission):
+ _context.action(
+ discriminator = self.discriminator(
+ ('z3ext.permissions.denyAll',
+ self.name, self.for_, tuple(permission))),
+ callable = directiveHandlerAll,
+ args = (self.name, 'denyPermissionToRole',
+ permission, 'denyall', self.for_))
+
+ def unsetAll(self, _context, permission):
+ _context.action(
+ discriminator = self.discriminator(
+ ('z3ext.permissions.unsetAll',
+ self.name, self.for_, tuple(permission))),
+ callable = directiveHandlerAll,
+ args = (self.name, 'unsetPermissionFromRole',
+ permission, 'unsetall', self.for_))
More information about the Checkins
mailing list