[Zope3-checkins] CVS: Zope3/src/zope/security - context.py:1.4 simplepolicies.py:1.5
Steve Alexander
steve@cat-box.net
Tue, 3 Jun 2003 11:09:55 -0400
Update of /cvs-repository/Zope3/src/zope/security
In directory cvs.zope.org:/tmp/cvs-serv4056/src/zope/security
Modified Files:
context.py simplepolicies.py
Log Message:
Improved formatting. New implements() style.
=== Zope3/src/zope/security/context.py 1.3 => 1.4 ===
--- Zope3/src/zope/security/context.py:1.3 Thu May 1 15:35:47 2003
+++ Zope3/src/zope/security/context.py Tue Jun 3 11:09:24 2003
@@ -11,29 +11,27 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Default ISecurityContext impl """
+"""Default ISecurityContext implementation."""
from zope.security.interfaces import ISecurityContext
+from zope.interface import implements
class SecurityContext:
- """
- Capture transient request-specific security information.
-
- Attribute( 'stack'
- , 'A stack of elements, each either be an ExecutableObject'
- 'or a tuple consisting of an ExecutableObject and a'
- 'custom SecurityPolicy.'
- )
+ """Capture transient request-specific security information.
- Attribute( 'user'
- , 'The AUTHENTICATED_USER for the request.'
- )
+ Attribute('stack',
+ 'A stack of elements, each either be an ExecutableObject or a'
+ ' tuple consisting of an ExecutableObject and a custom'
+ ' SecurityPolicy.'
+ )
+
+ Attribute('user',
+ 'The AUTHENTICATED_USER for the request.'
+ )
"""
+ implements(ISecurityContext)
- __implements__ = ISecurityContext
-
def __init__(self, user):
-
self.stack = []
self.user = user
self.objectCache = {}
=== Zope3/src/zope/security/simplepolicies.py 1.4 => 1.5 ===
--- Zope3/src/zope/security/simplepolicies.py:1.4 Thu May 1 15:35:47 2003
+++ Zope3/src/zope/security/simplepolicies.py Tue Jun 3 11:09:24 2003
@@ -11,33 +11,30 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Simple ISecurityPolicy implementations."""
+"""Simple ISecurityPolicy implementations."""
from zope.security.interfaces import ISecurityPolicy
from zope.security.management import system_user
import zope.security.checker
+from zope.interface import implements
class ParanoidSecurityPolicy:
- """
- Deny all access.
- """
- __implements__ = ISecurityPolicy
+ """Deny all access."""
+ implements(ISecurityPolicy)
def checkPermission(self, permission, object, context):
if permission is zope.security.checker.CheckerPublic:
- return 1
+ return True
if (context.user is system_user # no user
and not context.stack # no untrusted code
):
- return 1 # Nobody not to trust!
+ return True # Nobody not to trust!
- return 0
+ return False
class PermissiveSecurityPolicy:
- """
- Allow all access
- """
- __implements__ = ISecurityPolicy
+ """Allow all access."""
+ implements(ISecurityPolicy)
def checkPermission(self, permission, object, context):
- return 1
+ return True