[Checkins] SVN: z3c.objectpolicy/trunk/ eggify and add license
Adam Groszer
agroszer at gmail.com
Sat Mar 20 11:38:21 EDT 2010
Log message for revision 110093:
eggify and add license
Changed:
_U z3c.objectpolicy/trunk/
A z3c.objectpolicy/trunk/CHANGES.txt
A z3c.objectpolicy/trunk/LICENSE.txt
A z3c.objectpolicy/trunk/README.txt
A z3c.objectpolicy/trunk/bootstrap.py
A z3c.objectpolicy/trunk/buildout.cfg
A z3c.objectpolicy/trunk/setup.py
_U z3c.objectpolicy/trunk/src/
A z3c.objectpolicy/trunk/src/z3c/__init__.py
U z3c.objectpolicy/trunk/src/z3c/objectpolicy/interfaces.py
U z3c.objectpolicy/trunk/src/z3c/objectpolicy/objectpolicy.py
U z3c.objectpolicy/trunk/src/z3c/objectpolicy/tests.py
-=-
Property changes on: z3c.objectpolicy/trunk
___________________________________________________________________
Added: svn:ignore
+ .installed.cfg
bin
develop-eggs
parts
Added: z3c.objectpolicy/trunk/CHANGES.txt
===================================================================
--- z3c.objectpolicy/trunk/CHANGES.txt (rev 0)
+++ z3c.objectpolicy/trunk/CHANGES.txt 2010-03-20 15:38:21 UTC (rev 110093)
@@ -0,0 +1,8 @@
+=======
+CHANGES
+=======
+
+0.1.0 (unreleased)
+-----------------
+
+- ...
Property changes on: z3c.objectpolicy/trunk/CHANGES.txt
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision
Added: svn:eol-style
+ native
Added: z3c.objectpolicy/trunk/LICENSE.txt
===================================================================
--- z3c.objectpolicy/trunk/LICENSE.txt (rev 0)
+++ z3c.objectpolicy/trunk/LICENSE.txt 2010-03-20 15:38:21 UTC (rev 110093)
@@ -0,0 +1,44 @@
+Zope Public License (ZPL) Version 2.1
+
+A copyright notice accompanies this license document that identifies the
+copyright holders.
+
+This license has been certified as open source. It has also been designated as
+GPL compatible by the Free Software Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions in source code must retain the accompanying copyright
+notice, this list of conditions, and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the accompanying copyright
+notice, this list of conditions, and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+3. Names of the copyright holders must not be used to endorse or promote
+products derived from this software without prior written permission from the
+copyright holders.
+
+4. The right to distribute this software or to use it for any purpose does not
+give you the right to use Servicemarks (sm) or Trademarks (tm) of the
+copyright
+holders. Use of them is covered by separate agreement with the copyright
+holders.
+
+5. If any files are modified, you must cause the modified files to carry
+prominent notices stating that you changed the files and the date of any
+change.
+
+Disclaimer
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Property changes on: z3c.objectpolicy/trunk/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision
Added: svn:eol-style
+ native
Added: z3c.objectpolicy/trunk/README.txt
===================================================================
--- z3c.objectpolicy/trunk/README.txt (rev 0)
+++ z3c.objectpolicy/trunk/README.txt 2010-03-20 15:38:21 UTC (rev 110093)
@@ -0,0 +1,2 @@
+The objectpolicy package makes it easy to override the default
+zope.app.securitypolicy.zopepolicy on an object by object basis.
\ No newline at end of file
Property changes on: z3c.objectpolicy/trunk/README.txt
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision
Added: svn:eol-style
+ native
Added: z3c.objectpolicy/trunk/bootstrap.py
===================================================================
--- z3c.objectpolicy/trunk/bootstrap.py (rev 0)
+++ z3c.objectpolicy/trunk/bootstrap.py 2010-03-20 15:38:21 UTC (rev 110093)
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# 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()
+
+is_jython = sys.platform.startswith('java')
+
+try:
+ import pkg_resources
+except ImportError:
+ 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
+
+if sys.platform == 'win32':
+ def quote(c):
+ if ' ' in c:
+ return '"%s"' % c # work around spawn lamosity on windows
+ else:
+ return c
+else:
+ def quote (c):
+ return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws = pkg_resources.working_set
+
+if is_jython:
+ import subprocess
+
+ assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+ quote(tmpeggs), 'zc.buildout'],
+ env=dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ).wait() == 0
+
+else:
+ assert os.spawnle(
+ os.P_WAIT, sys.executable, quote (sys.executable),
+ '-c', quote (cmd), '-mqNxd', quote (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)
Property changes on: z3c.objectpolicy/trunk/bootstrap.py
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision
Added: svn:eol-style
+ native
Added: z3c.objectpolicy/trunk/buildout.cfg
===================================================================
--- z3c.objectpolicy/trunk/buildout.cfg (rev 0)
+++ z3c.objectpolicy/trunk/buildout.cfg 2010-03-20 15:38:21 UTC (rev 110093)
@@ -0,0 +1,25 @@
+[buildout]
+develop = .
+
+extends = http://download.zope.org/zope3.4/3.4.0/versions.cfg
+
+parts = test checker coverage-test coverage-report
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.objectpolicy [test]
+
+[checker]
+recipe = lovely.recipe:importchecker
+path = src/z3c/objectpolicy
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3c.objectpolicy [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
Property changes on: z3c.objectpolicy/trunk/buildout.cfg
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision
Added: svn:eol-style
+ native
Added: z3c.objectpolicy/trunk/setup.py
===================================================================
--- z3c.objectpolicy/trunk/setup.py (rev 0)
+++ z3c.objectpolicy/trunk/setup.py 2010-03-20 15:38:21 UTC (rev 110093)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2010 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
+
+$Id$
+"""
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup (
+ name='z3c.objectpolicy',
+ version = '0.1.0dev',
+ author = "Zope Foundation and Contributors",
+ author_email = "zope-dev at zope.org",
+ description = "objectpolicy for Zope3",
+ long_description=(
+ read('README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ license = "ZPL 2.1",
+ keywords = "zope3 z3c objectpolicy",
+ classifiers = [
+ 'Development Status :: 4 - Beta',
+ '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'],
+ url = 'http://cheeseshop.python.org/pypi/z3c.objectpolicy',
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['z3c'],
+ extras_require = dict(
+ test = [
+ 'z3c.coverage',
+ 'zope.app.securitypolicy',
+ 'zope.app.testing',
+ 'zope.configuration',
+ 'zope.testing',
+ ],
+ ),
+ install_requires = [
+ 'setuptools',
+ 'zope.component',
+ 'zope.interface',
+ 'zope.app.securitypolicy',
+ ],
+ zip_safe = False,
+)
\ No newline at end of file
Property changes on: z3c.objectpolicy/trunk/setup.py
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision
Added: svn:eol-style
+ native
Property changes on: z3c.objectpolicy/trunk/src
___________________________________________________________________
Added: svn:ignore
+ z3c.objectpolicy.egg-info
Added: z3c.objectpolicy/trunk/src/z3c/__init__.py
===================================================================
--- z3c.objectpolicy/trunk/src/z3c/__init__.py (rev 0)
+++ z3c.objectpolicy/trunk/src/z3c/__init__.py 2010-03-20 15:38:21 UTC (rev 110093)
@@ -0,0 +1,7 @@
+# this is a namespace package
+try:
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ import pkgutil
+ __path__ = pkgutil.extend_path(__path__, __name__)
Property changes on: z3c.objectpolicy/trunk/src/z3c/__init__.py
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision
Added: svn:eol-style
+ native
Modified: z3c.objectpolicy/trunk/src/z3c/objectpolicy/interfaces.py
===================================================================
--- z3c.objectpolicy/trunk/src/z3c/objectpolicy/interfaces.py 2010-03-20 14:07:20 UTC (rev 110092)
+++ z3c.objectpolicy/trunk/src/z3c/objectpolicy/interfaces.py 2010-03-20 15:38:21 UTC (rev 110093)
@@ -1,5 +1,16 @@
-# -*- coding: UTF-8 -*-
-
+##############################################################################
+#
+# Copyright (c) 2010 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.
+#
+##############################################################################
from zope.interface import Interface
class IObjectPolicyMarker(Interface):
@@ -17,11 +28,11 @@
permissionid -- A permission ID
principalid -- A principal ID (participation.principal.id)
default -- The default value proposed by AnnotationPrincipalPermissionManager
-
+
return:
one of zope.app.securitypolicy.interfaces.[Allow, Deny, Unset]
"""
-
+
def getRolePermission(self, manager, permissionid, roleid):
"""Return whether security policy allows permission
on the context object to the role.
@@ -31,45 +42,45 @@
which gets the permission from the annotations
permissionid -- A permission ID
roleid -- A role ID (determined by ZopeSecurityPolicy)
-
+
return:
one of zope.app.securitypolicy.interfaces.[Allow, Deny, Unset]
"""
-
+
def checkPermission(manager, permissionid):
"""Return whether security policy allows permission
on the context object.
-
+
manager -- The default Z3 ZopePolicy,
which can be used to get default permissions
permissionid -- A permission ID
-
+
The method should go through manager.participations.principal's
to check permissions, see checkPermissionForParticipation
-
+
return:
True -- access granted
False -- no access
"""
-
+
def checkPermissionForParticipation(manager, permissionid):
"""Go thrugh manager.participations.principal's
call self.checkPermissionForParticipant for each one
convinience method
-
+
return:
True -- access granted
False -- no access
"""
-
+
def checkPermissionForParticipant(self, manager, principal, permissionid):
"""Called by checkPermissionForParticipation for each principal
-
+
manager -- The default Z3 ZopePolicy,
which can be used to get default permissions
principal -- A principal
permissionid -- A permission ID
-
+
return:
True -- access granted
False -- no access
Modified: z3c.objectpolicy/trunk/src/z3c/objectpolicy/objectpolicy.py
===================================================================
--- z3c.objectpolicy/trunk/src/z3c/objectpolicy/objectpolicy.py 2010-03-20 14:07:20 UTC (rev 110092)
+++ z3c.objectpolicy/trunk/src/z3c/objectpolicy/objectpolicy.py 2010-03-20 15:38:21 UTC (rev 110093)
@@ -1,3 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2010 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.
+#
+##############################################################################
"""
The objectpolicy package makes it easy to override the default
zope.app.securitypolicy.zopepolicy on an object by object basis.
@@ -8,7 +21,8 @@
"""
-from zope import interface, component
+import zope.interface
+import zope.component
from zope.app.securitypolicy.zopepolicy import ZopeSecurityPolicy
from zope.security.checker import CheckerPublic
@@ -33,35 +47,31 @@
def checkPermission(self, permission, object):
if permission is CheckerPublic:
return True
-
+
object = removeSecurityProxy(object)
-
+
if IObjectPolicyMarker.providedBy(object):
- #print permission, str(object)
- #if 'Modi' in permission:
- # from pub.dbgpclient import brk
- # brk()
try:
adapted = IObjectPolicy(object)
except TypeError:
return self.checkZopePermission(permission, object)
-
+
return adapted.checkPermission(self, permission)
else:
return self.checkZopePermission(permission, object)
class ObjectPrincipalPermissionManager(AnnotationPrincipalPermissionManager):
- component.adapts(IObjectPolicyMarker)
- interface.implements(IPrincipalPermissionManager)
-
+ zope.component.adapts(IObjectPolicyMarker)
+ zope.interface.implements(IPrincipalPermissionManager)
+
def __init__(self, context):
super(ObjectPrincipalPermissionManager, self).__init__(context)
-
+
try:
self._adapted = IObjectPolicy(context)
except TypeError:
self.getSetting = self.getZopePrincipalSetting
-
+
def getPrincipalsForPermission(self, permission_id):
"""Get the principas that have a permission.
@@ -87,11 +97,11 @@
raise NotImplementedError("Seemed like nobody calls getPermissionsForPrincipal")
return super(ObjectPrincipalPermissionManager, self).getPermissionsForPrincipal(
principal_id)
-
+
def getZopePrincipalSetting(self, permission_id, principal_id, default=Unset):
return super(ObjectPrincipalPermissionManager, self).getSetting(
permission_id, principal_id, default)
-
+
def getSetting(self, permission_id, principal_id, default=Unset):
"""Get the setting for a permission and principal.
@@ -125,17 +135,17 @@
# """
class ObjectRolePermissionManager(AnnotationRolePermissionManager):
- component.adapts(IObjectPolicyMarker)
- interface.implements(IRolePermissionManager)
-
+ zope.component.adapts(IObjectPolicyMarker)
+ zope.interface.implements(IRolePermissionManager)
+
def __init__(self, context):
super(ObjectRolePermissionManager, self).__init__(context)
-
+
try:
self._adapted = IObjectPolicy(context)
except TypeError:
self.getSetting = self.getZopeRoleSetting
-
+
def getPermissionsForRole(self, role_id):
"""Get the premissions granted to a role.
@@ -161,11 +171,11 @@
print "ROLE:getRolesForPermission"
return super(ObjectRolePermissionManager, self).getRolesForPermission(
permission_id)
-
+
def getZopeRoleSetting(self, permission_id, role_id):
return super(ObjectRolePermissionManager, self).getSetting(
permission_id, role_id)
-
+
def getSetting(self, permission_id, role_id):
"""Return the setting for the given permission id and role id
@@ -186,7 +196,7 @@
print "ROLE:getRolesAndPermissions"
return super(ObjectRolePermissionManager, self).getRolesAndPermissions()
-
+
#def grantPermissionToRole(permission_id, role_id):
# """Bind the permission to the role.
# """
@@ -200,26 +210,25 @@
# """
class DefaultObjectPolicyAdapter(object):
- interface.implements(IObjectPolicy)
+ zope.interface.implements(IObjectPolicy)
def __init__(self, context):
- #context is a Person
self.context = context
def getPrincipalPermission(self, manager, permissionid, principalid, default):
#return the Z3 default permissions
return manager.getZopePrincipalSetting(
permissionid, principalid, default)
-
+
def getRolePermission(self, manager, permissionid, roleid):
#return the Z3 default permissions
return manager.getZopeRoleSetting(
permissionid, roleid)
-
+
def checkPermission(self, manager, permissionid):
#print permissionid, str(self.context)
return manager.checkZopePermission(permissionid, self.context)
-
+
def checkPermissionForParticipation(self, manager, permissionid):
object = self.context
seen = {}
@@ -239,7 +248,7 @@
seen[principal.id] = 1
return True
-
+
def checkPermissionForParticipant(self, manager, principal, permissionid):
return manager.cached_decision(
self.context, principal.id,
Modified: z3c.objectpolicy/trunk/src/z3c/objectpolicy/tests.py
===================================================================
--- z3c.objectpolicy/trunk/src/z3c/objectpolicy/tests.py 2010-03-20 14:07:20 UTC (rev 110092)
+++ z3c.objectpolicy/trunk/src/z3c/objectpolicy/tests.py 2010-03-20 15:38:21 UTC (rev 110093)
@@ -1,3 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2010 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.
+#
+##############################################################################
import unittest
from zope import component
from zope.app.testing import placelesssetup
More information about the checkins
mailing list