Skip to content

Commit

Permalink
Doc cross-refs and cleanup for management.rst/py
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 14, 2017
1 parent ed8946b commit e504906
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
7 changes: 3 additions & 4 deletions docs/api/management.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
:mod:`zope.security.management`
===============================
==========================
zope.security.management
==========================

.. automodule:: zope.security.management
:members:
:member-order: bysource
32 changes: 20 additions & 12 deletions src/zope/security/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Default 'ISecurityManagement' and 'IInteractionManagement' implementation
"""
Default :class:`zope.security.interfaces.ISecurityManagement` and
:class:`zope.security.interfaces.IInteractionManagement` implementation.
Note that this module itself provides those interfaces.
"""

from zope.interface import moduleProvides
Expand Down Expand Up @@ -58,6 +62,7 @@ def setSecurityPolicy(aSecurityPolicy):
#

def queryInteraction():
"""Return a current interaction, if there is one."""
return getattr(thread_local, 'interaction', None)

def getInteraction():
Expand All @@ -70,7 +75,10 @@ def getInteraction():
class ExistingInteraction(ValueError,
AssertionError, #BBB
):
pass
"""
The exception that :func:`newInteraction` will raise if called
during an existing interaction.
"""

def newInteraction(*participations):
"""Start a new interaction."""
Expand Down Expand Up @@ -109,16 +117,16 @@ def restoreInteraction():
def checkPermission(permission, object, interaction=None):
"""Return whether security policy allows permission on object.
'permission' is a permission name.
'object' is the object being accessed according to the permission.
'interaction' is an interaction, providing access to information
such as authenticated principals. If it is None, the current
interaction is used.
checkPermission is guaranteed to return True if permission is
CheckerPublic or None.
:param str permission: A permission name.
:param object: The object being accessed according to the permission.
:param interaction: An interaction, providing access to information
such as authenticated principals. If it is None, the current
interaction is used.
:return: A boolean value. ``checkPermission`` is guaranteed to
return ``True`` if *permission* is
:data:`zope.security.checker.CheckerPublic` or ``None``.
:raise NoInteraction: If there is no current interaction and no
interaction argument was given.
"""
if permission is CheckerPublic or permission is None:
return True
Expand Down

0 comments on commit e504906

Please sign in to comment.