Commit 4ab8bc44 authored by 's avatar

final fixup to SecurityInfo interface names

parent 2c299351
...@@ -88,7 +88,11 @@ ...@@ -88,7 +88,11 @@
a declarative style of associating access control information a declarative style of associating access control information
with class attributes. with class attributes.
add example here More information on using SecurityInfo and guide to Zope security
for developers can be found in the dev.zope.org "Declarative Security"
project:
http://dev.zope.org/Wikis/DevSite/Projects/DeclarativeSecurity
While SecurityInfo objects largely remove the need for Python While SecurityInfo objects largely remove the need for Python
programmers to care about the underlying implementation, there programmers to care about the underlying implementation, there
...@@ -144,21 +148,36 @@ class SecurityInfo(Acquisition.Implicit): ...@@ -144,21 +148,36 @@ class SecurityInfo(Acquisition.Implicit):
self._warnings = 1 self._warnings = 1
self.names[name] = access self.names[name] = access
public__roles__=ACCESS_PRIVATE declarePublic__roles__=ACCESS_PRIVATE
def public(self, *names): def declarePublic(self, *names):
"""Declare names to be publicly accessible.""" """Declare names to be publicly accessible."""
self._setaccess(names, ACCESS_PUBLIC) self._setaccess(names, ACCESS_PUBLIC)
private__roles__=ACCESS_PRIVATE declarePrivate__roles__=ACCESS_PRIVATE
def private(self, *names): def declarePrivate(self, *names):
"""Declare names to be inaccessible to restricted code.""" """Declare names to be inaccessible to restricted code."""
self._setaccess(names, ACCESS_PRIVATE) self._setaccess(names, ACCESS_PRIVATE)
protected__roles__=ACCESS_PRIVATE declareProtected__roles__=ACCESS_PRIVATE
def protected(self, permission_name, *names): def declareProtected(self, permission_name, *names):
"""Declare names to be associated with a permission.""" """Declare names to be associated with a permission."""
self._setaccess(names, permission_name) self._setaccess(names, permission_name)
objectPublic__roles__=ACCESS_PRIVATE
def objectPublic(self):
"""Declare names to be publicly accessible."""
self._setaccess((), ACCESS_PUBLIC)
objectPrivate__roles__=ACCESS_PRIVATE
def objectPrivate(self):
"""Declare names to be inaccessible to restricted code."""
self._setaccess((), ACCESS_PRIVATE)
objectProtected__roles__=ACCESS_PRIVATE
def objectProtected(self, permission_name):
"""Declare names to be associated with a permission."""
self._setaccess((), permission_name)
setDefaultRoles__roles__=ACCESS_PRIVATE setDefaultRoles__roles__=ACCESS_PRIVATE
def setDefaultRoles(self, permission_name, roles): def setDefaultRoles(self, permission_name, roles):
"""Declare default roles for a permission""" """Declare default roles for a permission"""
...@@ -180,6 +199,7 @@ class SecurityInfo(Acquisition.Implicit): ...@@ -180,6 +199,7 @@ class SecurityInfo(Acquisition.Implicit):
""" """
self.access = access self.access = access
class ClassSecurityInfo(SecurityInfo): class ClassSecurityInfo(SecurityInfo):
"""Encapsulate security information for class objects.""" """Encapsulate security information for class objects."""
...@@ -288,10 +308,12 @@ class ModuleSecurityInfo(SecurityInfo): ...@@ -288,10 +308,12 @@ class ModuleSecurityInfo(SecurityInfo):
LOG('SecurityInfo', WARNING, 'Module "%s" had conflicting ' LOG('SecurityInfo', WARNING, 'Module "%s" had conflicting '
'security declarations' % dict['__name__']) 'security declarations' % dict['__name__'])
def protected(self, permission_name, *names): declareProtected__roles__=ACCESS_PRIVATE
def declareProtected(self, permission_name, *names):
"""Cannot declare module names protected.""" """Cannot declare module names protected."""
pass pass
setDefaultRoles__roles__=ACCESS_PRIVATE
def setDefaultRoles(self, permission_name, roles): def setDefaultRoles(self, permission_name, roles):
"""Cannot set default roles for permissions in a module.""" """Cannot set default roles for permissions in a module."""
pass pass
......
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