[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security - Checker.py:1.1.4.5.4.1 Proxy.py:1.1.4.1.8.1

Jim Fulton jim@zope.com
Wed, 29 May 2002 11:10:26 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Security
In directory cvs.zope.org:/tmp/cvs-serv12181/lib/python/Zope/Security

Modified Files:
      Tag: Zope3InWonderland-branch
	Checker.py Proxy.py 
Log Message:
- Added permission_id attribute to adapter and utility directives.

- Got rid of old getView, getResource, and getDefaultViewName.
  Renamed getRequestView to getView (and so on).

  Changed view interface to use context, rather than getContext.

  Introduced notion of presentation types (e.g. IBrowserPresentation, 
  which is cleaner than IBrowserPublisher).

- Began converting to get/queryFoo, which is much nicer.

- Many formatting fixups.



=== Zope3/lib/python/Zope/Security/Checker.py 1.1.4.5 => 1.1.4.5.4.1 ===
     return Checker(data.get)
 
+def InterfaceChecker(interface, permission_id=CheckerPublic):
+    return NamesChecker(interface.names(), permission_id)
+
 def MultiChecker(specs):
     """Create a checker from a sequence of specifications
 
@@ -203,8 +206,6 @@
 
 def getCheckerForInstancesOf(class_):
     return _checkers.get(class_)
-    
-    
 
 def defineChecker(type_, checker):
     """Define a checker for a given type of object
@@ -214,8 +215,8 @@
     """
     if type_ in _checkers:
         raise DuplicationError(type_)
-    _checkers[type_] = checker
-
+    _checkers[type_] = checker    
+    
 
 NoProxy = object()
 


=== Zope3/lib/python/Zope/Security/Proxy.py 1.1.4.1 => 1.1.4.1.8.1 ===
 from Checker import ProxyFactory
 
+
+
+def getTestProxyItems(proxy):
+    """Try to get checker names and permissions for testing
+
+    If this succeeds, a sorted sequence of items is returned,
+    otherwise, None is retirned.
+    """
+    checker = getChecker(proxy)
+    func = checker.getPermission_func()
+    dict = getattr(func, '__self__', None)
+    if dict is None:
+        return None
+    items = dict.items()
+    items.sort()
+    return items
+