Commit bb5234e6 authored by Chris McDonough's avatar Chris McDonough

Added roles argument to validate and validateValue methods.

parent b4a35249
...@@ -85,11 +85,13 @@ ...@@ -85,11 +85,13 @@
__doc__='''short description __doc__='''short description
$Id: SecurityManager.py,v 1.2 2000/05/11 18:54:13 jim Exp $''' $Id: SecurityManager.py,v 1.3 2001/01/10 20:20:46 chrism Exp $'''
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.3 $'[11:-2]
import ZopeSecurityPolicy, os, string import ZopeSecurityPolicy, os, string
_noroles = ZopeSecurityPolicy._noroles
try: max_stack_size=string.atoi(os.environ.get('Z_MAX_STACK_SIZE','100')) try: max_stack_size=string.atoi(os.environ.get('Z_MAX_STACK_SIZE','100'))
except: max_stack_size=100 except: max_stack_size=100
...@@ -115,7 +117,8 @@ class SecurityManager: ...@@ -115,7 +117,8 @@ class SecurityManager:
self._context=context self._context=context
self._policy=None self._policy=None
def validate(self, accessed=None, container=None, name=None, value=None): def validate(self, accessed=None, container=None, name=None, value=None,
roles=_noroles):
"""Validate access. """Validate access.
Arguments: Arguments:
...@@ -128,6 +131,8 @@ class SecurityManager: ...@@ -128,6 +131,8 @@ class SecurityManager:
value -- The value retrieved though the access. value -- The value retrieved though the access.
roles -- The roles of the object if already known.
The arguments may be provided as keyword arguments. Some of these The arguments may be provided as keyword arguments. Some of these
arguments may be ommitted, however, the policy may reject access arguments may be ommitted, however, the policy may reject access
in some cases when arguments are ommitted. It is best to provide in some cases when arguments are ommitted. It is best to provide
...@@ -136,15 +141,15 @@ class SecurityManager: ...@@ -136,15 +141,15 @@ class SecurityManager:
policy=self._policy policy=self._policy
if policy is None: policy=_defaultPolicy if policy is None: policy=_defaultPolicy
return policy.validate(accessed, container, name, value, return policy.validate(accessed, container, name, value,
self._context) self._context, roles)
def validateValue(self, value): def validateValue(self, value, roles=_noroles):
"""Convenience for common case of simple value validation. """Convenience for common case of simple value validation.
""" """
policy=self._policy policy=self._policy
if policy is None: policy=_defaultPolicy if policy is None: policy=_defaultPolicy
return policy.validate(None, None, None, value, return policy.validate(None, None, None, value,
self._context) self._context, roles)
def checkPermission(self, permission, object): def checkPermission(self, permission, object):
"""Check whether the security context allows the given permission on """Check whether the security context allows the given permission on
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment