[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - SimpleSecurityPolicies.py:1.1.2.2
Martijn Pieters
mj@zope.com
Tue, 4 Dec 2001 11:20:20 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv13405
Modified Files:
Tag: Zope-3x-branch
SimpleSecurityPolicies.py
Log Message:
Add name based security policy; base acces solely on the name used.
=== Zope3/lib/python/Zope/App/Security/SimpleSecurityPolicies.py 1.1.2.1 => 1.1.2.2 ===
def checkPermission( self, permission, object, context ):
return 1
+
+class NameBasedSecurityPolicy:
+ """ Allow access based on traversed name.
+
+ The constructor takes a callable object, which is passed the name of the
+ item accessed, or None. This method should either pass or raise
+ Zope.Exceptions.Unauthorized.
+
+ """
+
+ __implements__ = ISecurityPolicy
+
+ def __init__(self, nameChecker):
+ self._nameChecker = nameChecker
+
+ def validate(self, name, value, context):
+ self._nameChecker(name)
+
+ def checkPermission(self, permission, object, context):
+ return 1
+