[Zope3-checkins] CVS: Zope3/src/zope/security - __init__.py:1.3.48.1 interfaces.py:1.8.2.3

Marius Gedminas marius at pov.lt
Mon Mar 8 16:51:29 EST 2004


Update of /cvs-repository/Zope3/src/zope/security
In directory cvs.zope.org:/tmp/cvs-serv19054/src/zope/security

Modified Files:
      Tag: mgedmin-events2-branch
	__init__.py interfaces.py 
Log Message:
Added a checkPermission method to zope.security.



=== Zope3/src/zope/security/__init__.py 1.3 => 1.3.48.1 ===
--- Zope3/src/zope/security/__init__.py:1.3	Thu May 22 15:40:32 2003
+++ Zope3/src/zope/security/__init__.py	Mon Mar  8 16:50:58 2004
@@ -5,3 +5,28 @@
 # XXX There's a circular import problem with the proxy package.
 # The proxy framework needs some refactoring, but not today.
 import zope.proxy
+
+from zope.security.checker import CheckerPublic as _CheckerPublic
+from zope.security.management import getInteraction as _getInteraction
+from zope.security.management import getSecurityPolicy as _getSecurityPolicy
+
+def checkPermission(permission, object, interaction=None):
+    """Return whether security policy allows permission on object.
+
+    Arguments:
+    permission -- A permission name
+    object -- The object being accessed according to the permission
+    interaction -- An interaction, which provides 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.
+    """
+    if permission is None or permission is _CheckerPublic:
+        return True
+    if interaction is None:
+        interaction = _getInteraction()
+    policy = _getSecurityPolicy()
+    return policy.checkPermission(permission, object, interaction)
+


=== Zope3/src/zope/security/interfaces.py 1.8.2.2 => 1.8.2.3 ===
--- Zope3/src/zope/security/interfaces.py:1.8.2.2	Mon Mar  8 13:43:44 2004
+++ Zope3/src/zope/security/interfaces.py	Mon Mar  8 16:50:58 2004
@@ -32,6 +32,21 @@
         """
 
 
+class ISecurityChecking(Interface):
+    """Public security API."""
+
+    def checkPermission(permission, object, interaction=None):
+        """Return whether security policy allows permission on object.
+
+        Arguments:
+        permission -- A permission name
+        object -- The object being accessed according to the permission
+        interaction -- An interaction, which provides access to information
+            such as authenticated principals.  If it is None, the current
+            interaction is used.
+        """
+
+
 class ISecurityProxyFactory(Interface):
 
     def __call__(object, checker=None, interaction=None):




More information about the Zope3-Checkins mailing list