[Zope3-checkins] SVN: Zope3/trunk/src/zope/security/ Merged from jim-work branch r26112

Jim Fulton jim at zope.com
Tue Jul 6 16:49:04 EDT 2004


Log message for revision 26139:
Merged from jim-work branch r26112

Added missing security declarations to make interface declaration
introspection work on proxied classes.



-=-
Modified: Zope3/trunk/src/zope/security/checker.py
===================================================================
--- Zope3/trunk/src/zope/security/checker.py	2004-07-06 20:18:47 UTC (rev 26138)
+++ Zope3/trunk/src/zope/security/checker.py	2004-07-06 20:49:04 UTC (rev 26139)
@@ -33,12 +33,10 @@
 import weakref
 import zope.interface.interface
 import zope.interface.interfaces
+import zope.interface.declarations
 
 from zope.interface import directlyProvides, Interface, implements
 from zope.interface.interfaces import IInterface, IDeclaration
-from zope.interface.declarations import ProvidesClass
-from zope.interface.declarations import Implements
-from zope.interface.declarations import Declaration
 from zope.security.interfaces import IChecker, INameBasedChecker
 from zope.security.interfaces import ISecurityProxyFactory
 from zope.security.management import getSecurityPolicy, queryInteraction
@@ -542,7 +540,8 @@
 
 _callableChecker = NamesChecker(['__str__', '__name__', '__call__'])
 _typeChecker = NamesChecker(
-    ['__str__', '__name__', '__module__', '__bases__', '__mro__'])
+    ['__str__', '__name__', '__module__', '__bases__', '__mro__',
+     '__implemented__'])
 _namedChecker = NamesChecker(['__name__'])
 
 _iteratorChecker = NamesChecker(['next', '__iter__'])
@@ -644,9 +643,10 @@
         ),
     zope.interface.interface.Method: InterfaceChecker(
                                         zope.interface.interfaces.IMethod),
-    ProvidesClass: _Declaration_checker,
-    Implements: _Declaration_checker,
-    Declaration: _Declaration_checker,
+    zope.interface.declarations.ProvidesClass: _Declaration_checker,
+    zope.interface.declarations.ClassProvides: _Declaration_checker,
+    zope.interface.declarations.Implements: _Declaration_checker,
+    zope.interface.declarations.Declaration: _Declaration_checker,
 }
 
 def _clear():

Modified: Zope3/trunk/src/zope/security/tests/test_standard_checkers.py
===================================================================
--- Zope3/trunk/src/zope/security/tests/test_standard_checkers.py	2004-07-06 20:18:47 UTC (rev 26138)
+++ Zope3/trunk/src/zope/security/tests/test_standard_checkers.py	2004-07-06 20:49:04 UTC (rev 26139)
@@ -453,8 +453,35 @@
     >>> check_forbidden_call(list, p)
     'ForbiddenAttribute: __iter__'
     """
-    
 
+def test_interfaces_and_declarations():
+    """Test that we can still use interfaces though proxies
+
+    >>> import zope.interface
+    >>> class I(zope.interface.Interface):
+    ...     pass
+    >>> class IN(zope.interface.Interface):
+    ...     pass
+    >>> class II(zope.interface.Interface):
+    ...     pass
+    >>> class N(object):
+    ...     zope.interface.implements(I)
+    ...     zope.interface.classProvides(IN)
+    >>> n = N()
+    >>> zope.interface.directlyProvides(n, II)
+    >>> from zope.security.checker import ProxyFactory
+    >>> N = ProxyFactory(N)
+    >>> n = ProxyFactory(n)
+    >>> I.implementedBy(N)
+    True
+    >>> IN.providedBy(N)
+    True
+    >>> I.providedBy(n)
+    True
+    >>> II.providedBy(n)
+    True
+    """
+
     
 from zope.testing.doctestunit import DocTestSuite
 



More information about the Zope3-Checkins mailing list