[Zope3-checkins] CVS: Zope3/src/zope/app/security - permission.py:1.1 principal.py:1.1 role.py:1.1 zopesecuritypolicy.py:1.3 permissionfield.py:NONE
Jim Fulton
jim@zope.com
Thu, 26 Dec 2002 13:49:37 -0500
Update of /cvs-repository/Zope3/src/zope/app/security
In directory cvs.zope.org:/tmp/cvs-serv19745
Modified Files:
zopesecuritypolicy.py
Added Files:
permission.py principal.py role.py
Removed Files:
permissionfield.py
Log Message:
Added functions for checking validity of permission, role, and
principal ids.
Updated global grants to perform these chacks.
Renamed and consolidated a number of files in the ongoing quest to get
to single-line imports.
=== Added File Zope3/src/zope/app/security/permission.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""These are the interfaces for the common fields.
$Id: permission.py,v 1.1 2002/12/26 18:49:06 jim Exp $
"""
from zope.schema import ValueSet
from zope.schema.interfaces import ValidationError
from zope.component import getService
from zope.app.interfaces.security import IPermissionField
def checkPermission(context, permission_id):
if not getService(context, 'Permissions').getPermission(permission_id):
raise ValueError("Undefined permission id", permission_id)
class PermissionField(ValueSet):
__doc__ = IPermissionField.__doc__
__implements__ = IPermissionField
def _validate(self, value):
super(PermissionField, self)._validate(value)
service = getService(self.context, 'Permissions')
if service.getPermission(value.getId()) is None:
raise ValidationError("Unknown permission", value)
=== Added File Zope3/src/zope/app/security/principal.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""These are the interfaces for the common fields.
$Id: principal.py,v 1.1 2002/12/26 18:49:06 jim Exp $
"""
from zope.exceptions import NotFoundError
from zope.component import getService
def checkPrincipal(context, principal_id):
try:
if getService(context, 'Authentication').getPrincipal(principal_id):
return
except NotFoundError:
pass
raise ValueError("Undefined principal id", principal_id)
=== Added File Zope3/src/zope/app/security/role.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""These are the interfaces for the common fields.
$Id: role.py,v 1.1 2002/12/26 18:49:06 jim Exp $
"""
from zope.component import getService
def checkRole(context, role_id):
if not getService(context, 'Roles').getRole(role_id):
raise ValueError("Undefined role id", role_id)
=== Zope3/src/zope/app/security/zopesecuritypolicy.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/security/zopesecuritypolicy.py:1.2 Wed Dec 25 09:13:16 2002
+++ Zope3/src/zope/app/security/zopesecuritypolicy.py Thu Dec 26 13:49:06 2002
@@ -36,12 +36,10 @@
from zope.app.security.registries.permissionregistry import permissionRegistry
from zope.app.security.registries.principalregistry import principalRegistry
from zope.app.security.registries.roleregistry import roleRegistry
-from zope.app.security.grants.principalpermissionmanager \
+from zope.app.security.grants.principalpermission \
import principalPermissionManager
-from zope.app.security.grants.rolepermissionmanager \
- import rolePermissionManager
-from zope.app.security.grants.principalrolemanager \
- import principalRoleManager
+from zope.app.security.grants.rolepermission import rolePermissionManager
+from zope.app.security.grants.principalrole import principalRoleManager
from zope.app.security.settings import Allow, Deny
getPermissionsForPrincipal = \
=== Removed File Zope3/src/zope/app/security/permissionfield.py ===