[Zope3-checkins] SVN: Zope3/branches/dominik-locatableadapters/src/zope/app/ revert keyrefence and intid changes

Dominik Huber dominik.huber at projekt01.ch
Wed Apr 20 07:18:16 EDT 2005


Log message for revision 30053:
  revert keyrefence and intid changes
  add additional locating trusted adapter factory
  
  todo:
  - how to handle null adapters?
  - implementation is pretty implicit
  

Changed:
  U   Zope3/branches/dominik-locatableadapters/src/zope/app/component/metaconfigure.py
  U   Zope3/branches/dominik-locatableadapters/src/zope/app/component/tests/test_directives.py
  U   Zope3/branches/dominik-locatableadapters/src/zope/app/intid/__init__.py
  U   Zope3/branches/dominik-locatableadapters/src/zope/app/keyreference/persistent.py
  U   Zope3/branches/dominik-locatableadapters/src/zope/app/security/adapter.py

-=-
Modified: Zope3/branches/dominik-locatableadapters/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/branches/dominik-locatableadapters/src/zope/app/component/metaconfigure.py	2005-04-20 09:47:30 UTC (rev 30052)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/component/metaconfigure.py	2005-04-20 11:18:16 UTC (rev 30053)
@@ -29,9 +29,10 @@
 from zope.security.proxy import Proxy
 
 from zope.app import zapi
-from zope.app.security.adapter import TrustedAdapterFactory, UntrustedAdapterFactory
+from zope.app.security.adapter import LocatingTrustedAdapterFactory
+from zope.app.security.adapter import LocatingUntrustedAdapterFactory
+from zope.app.security.adapter import TrustedAdapterFactory
 
-
 PublicPermission = 'zope.Public'
 
 def handler(methodName, *args, **kwargs):
@@ -177,12 +178,18 @@
         checker = InterfaceChecker(provides, permission)
         factory = _protectedFactory(factory, checker)
 
-        # handle untrusted adapter that requires dedicated permissions
-        if permission != PublicPermission and not trusted:
-            factory = UntrustedAdapterFactory(factory)
-            
-    if trusted:
-        factory = TrustedAdapterFactory(factory)
+    # invoke custom adapter factories
+    if permission is None or permission is CheckerPublic:
+        if trusted:
+            # trusted adapters that requires no permission
+            factory = TrustedAdapterFactory(factory)
+    else:
+        if trusted:
+            # trusted adapters that requires any dedicated permission
+            factory = LocatingTrustedAdapterFactory(factory)
+        else:
+            # untrusted adapters that requires any dedicated permission
+            factory = LocatingUntrustedAdapterFactory(factory)
 
     _context.action(
         discriminator = ('adapter', for_, provides, name),

Modified: Zope3/branches/dominik-locatableadapters/src/zope/app/component/tests/test_directives.py
===================================================================
--- Zope3/branches/dominik-locatableadapters/src/zope/app/component/tests/test_directives.py	2005-04-20 09:47:30 UTC (rev 30052)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/component/tests/test_directives.py	2005-04-20 11:18:16 UTC (rev 30053)
@@ -343,16 +343,10 @@
             '''
             )))
 
-        # With an unproxied none-locatable object we get a location-proxied
-        # object back
+        # With an unproxied object, business as usual
         ob = Content()
-        from zope.app.location import LocationProxy
-        self.assertEqual(type(I1(ob)), LocationProxy)
+        self.assertEqual(type(I1(ob)), type(A1()))
 
-        # if we remove the location proxy the content object appears
-        from zope.proxy import removeAllProxies
-        self.assertEqual(type(removeAllProxies(I1(ob))), type(A1()))
-
         # Now with a proxied object:
         from zope.security.checker import ProxyFactory
         p = ProxyFactory(ob)
@@ -470,15 +464,7 @@
         content = Content()
         a1 = A1()
         a2 = A2()
-        from zope.app.location import LocationProxy
-        self.assertEqual(type(zapi.queryMultiAdapter((content, a1, a2), I3)), LocationProxy)
-
-        # TODO: I do not understand that test
-        # a3 = ProxyFactory(zapi.queryMultiAdapter((content, a1, a2), I3))
-        # workaround start
-        from zope.proxy import removeAllProxies
-        a3 = ProxyFactory(removeAllProxies(zapi.queryMultiAdapter((content, a1, a2), I3)))
-        # workaround end
+        a3 = ProxyFactory(zapi.queryMultiAdapter((content, a1, a2), I3))
         self.assertEqual(a3.__class__, A3)
         items = [item[0] for item in getTestProxyItems(a3)]
         self.assertEqual(items, ['f1', 'f2', 'f3'])
@@ -506,6 +492,7 @@
               factory="zope.app.component.tests.adapter.A3"
               provides="zope.app.component.tests.adapter.I3"
               for=""
+              trusted="True"
               />
             '''
             )))
@@ -582,15 +569,7 @@
             '''
             )))
 
-        from zope.app.location import LocationProxy
-        self.assertEqual(type(IApp(Content())), LocationProxy)
-
-        # TODO: I do not understand that test
-        #adapter = ProxyFactory(IApp(Content()))
-        # workaround start
-        from zope.proxy import removeAllProxies
-        adapter = ProxyFactory(removeAllProxies(IApp(Content())))
-        # workaround end
+        adapter = ProxyFactory(IApp(Content()))
         items = [item[0] for item in getTestProxyItems(adapter)]
         self.assertEqual(items, ['a', 'f'])
         self.assertEqual(removeSecurityProxy(adapter).__class__, Comp)
@@ -606,15 +585,7 @@
             '''
             )))
 
-        from zope.app.location import LocationProxy
-        self.assertEqual(type(IApp(Content())), LocationProxy)
-
-        # TODO: I do not understand that test
-        #adapter = ProxyFactory(IApp(Content()))
-        # workaround start
-        from zope.proxy import removeAllProxies
-        adapter = ProxyFactory(removeAllProxies(IApp(Content())))
-        # workaround end
+        adapter = ProxyFactory(IApp(Content()))
         items = [item[0] for item in getTestProxyItems(adapter)]
         self.assertEqual(items, ['a', 'f'])
         self.assertEqual(removeSecurityProxy(adapter).__class__, Comp)

Modified: Zope3/branches/dominik-locatableadapters/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/branches/dominik-locatableadapters/src/zope/app/intid/__init__.py	2005-04-20 09:47:30 UTC (rev 30052)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/intid/__init__.py	2005-04-20 11:18:16 UTC (rev 30053)
@@ -27,7 +27,7 @@
 
 from zope.event import notify
 from zope.interface import implements
-from zope.proxy import removeAllProxies
+from zope.security.proxy import removeSecurityProxy
 
 from zope.app import zapi
 from zope.app.container.contained import Contained
@@ -103,7 +103,7 @@
 
     def register(self, ob):
         # Note that we'll still need to keep this proxy removal.
-        ob = removeAllProxies(ob)
+        ob = removeSecurityProxy(ob)
         ref = IKeyReference(ob)
         if ref in self.ids:
             return self.ids[ref]

Modified: Zope3/branches/dominik-locatableadapters/src/zope/app/keyreference/persistent.py
===================================================================
--- Zope3/branches/dominik-locatableadapters/src/zope/app/keyreference/persistent.py	2005-04-20 09:47:30 UTC (rev 30052)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/keyreference/persistent.py	2005-04-20 11:18:16 UTC (rev 30053)
@@ -23,16 +23,9 @@
 from ZODB.interfaces import IConnection
 import zope.interface
 
-from zope.app.location import Location
-
 import zope.app.keyreference.interfaces
 
-# TODO: I do not understand that test
-# I get pickable Errors within the functional tests of zope.app.intid
-# The reference derives from Location to prevent its location-proxying
-# by the trusted adapters facility. 
-
-class KeyReferenceToPersistent(Location):
+class KeyReferenceToPersistent(object):
     """An IReference for persistent object which is comparable.
 
     These references compare by _p_oids of the objects they reference.

Modified: Zope3/branches/dominik-locatableadapters/src/zope/app/security/adapter.py
===================================================================
--- Zope3/branches/dominik-locatableadapters/src/zope/app/security/adapter.py	2005-04-20 09:47:30 UTC (rev 30052)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/security/adapter.py	2005-04-20 11:18:16 UTC (rev 30053)
@@ -21,6 +21,131 @@
 from zope.app.location import ILocation, Location, LocationProxy
 
 
+class TrustedAdapterFactoryMixin(object):
+    """Adapt an adapter factory to to provide trusted adapters
+
+    Trusted adapters always adapt unproxied objects. If asked to
+    adapt any proxied objects, it will unproxy them and then security-proxy
+    the resulting adapter (S) unless the adapted object were unproxied
+    before (N).
+
+    We account two different base use cases S (security-proxied) and N
+    (not security-proxied).
+
+        S.  security proxy > adapter > object(s)
+        N.  adapter > object(s)
+        R.  adapter > security proxy(s) > object(s) (Untrusted adapters)
+
+    Suppose we have an adapter factory:
+
+        >>> class A(object):
+        ...     def __init__(self, context):
+        ...         self.context = context
+
+    Now, suppose have an object and proxy it:
+
+        >>> o = []
+        >>> p = ProxyFactory(o)
+
+    If we adapt it the result is regularly (R) not security-proxied
+    but the object it adapts still is:
+
+        >>> a = A(p)
+        >>> type(a).__name__
+        'A'
+        >>> type(a.context).__name__
+        '_Proxy'
+
+    Now, will we will adapt our adapter factory to a trusted adapter factory
+    mixin:
+
+        >>> TA = TrustedAdapterFactoryMixin(A)
+
+    S. Adaption of security-proxied objects
+    If we use it the adapter is security-proxied, but it adapts anymore.
+    (We actually have to remove the adapter to get to the adapted object
+    in this case.):
+
+        >>> a = TA(p)
+        >>> type(a).__name__
+        '_Proxy'
+        >>> a = removeSecurityProxy(a)
+        >>> type(a).__name__
+        'A'
+        >>> type(a.context).__name__
+        'list'
+
+    This works with multiple objects too:
+
+        >>> class M(object):
+        ...     def __init__(self, *context):
+        ...         self.context = context
+
+        >>> TM = TrustedAdapterFactoryMixin(M)
+
+        >>> o2 = []
+        >>> o3 = []
+
+        >>> a = TM(p, o2, o3)
+        >>> type(a).__name__
+        '_Proxy'
+        >>> a = removeSecurityProxy(a)
+        >>> a.context[0] is o, a.context[1] is o2, a.context[2] is o3
+        (True, True, True)
+
+        >>> a = TM(p, ProxyFactory(o2), ProxyFactory(o3))
+        >>> type(a).__name__
+        '_Proxy'
+        >>> a = removeSecurityProxy(a)
+        >>> a.context[0] is o, a.context[1] is o2, a.context[2] is o3
+        (True, True, True)
+
+    N. Adaption of none-security-proxied objects
+    In cases where the first object that should be adapted is not
+    security-proxied the resulting adapter is not security-proxied too:
+
+        >>> a = TA(o)
+        >>> type(a).__name__
+        'A'
+        >>> type(a.context).__name__
+        'list'
+
+        >>> a = TM(o, o2, o3)
+        >>> type(a).__name__
+        'M'
+        >>> a.context[0] is o, a.context[1] is o2, a.context[2] is o3
+        (True, True, True)
+
+    The factory adapter has the __name__ and __module__ of the
+    factory it adapts:
+
+        >>> (TA.__module__, TA.__name__) == (A.__module__, A.__name__)
+        True
+
+    """
+    def __init__(self, factory):
+        self.factory = factory
+        self.__name__ = factory.__name__
+        self.__module__ = factory.__module__
+
+    # protected methods
+    def _customize(self, adapter, context):
+        """Subclasses might overwrite this method."""
+        return adapter
+
+    def __call__(self, *args):
+        for arg in args:
+            if removeSecurityProxy(arg) is not arg:
+                args = map(removeSecurityProxy, args)
+                adapter = self.factory(*args)
+                adapter = self._customize(adapter, args[0])
+                return ProxyFactory(adapter)
+
+        adapter = self.factory(*args)
+        adapter = self._customize(adapter, args[0])
+        return adapter
+
+
 def assertLocation(adapter, parent):
     """Assert locatable adapters.
 
@@ -30,7 +155,7 @@
     
     Arguments
     ---------
-    adapter - proxied or unproxied adapter
+    adapter - unproxied adapter
     parent - unproxied locatable object
 
     Usage
@@ -77,8 +202,8 @@
         >>> type(b1).__name__
         'B'
 
-    C. In those cases where the parent is provided by the adapter itself, the adapter
-    keeps its regular-parent:
+    C. In those cases where the parent is provided by the adapter itself, the
+    adapter keeps its regular-parent:
 
         >>> regularparent = Location()
 
@@ -113,235 +238,315 @@
         return adapter
 
 
-class TrustedAdapterFactory(object):
+class TrustedAdapterFactory(TrustedAdapterFactoryMixin):
     """Adapt an adapter factory to to provide trusted adapters
 
-       Trusted adapters always adapt unproxied objects.  If asked to
-       adapt any proxied objects, it will unproxy them and then proxy the
-       resulting adapter.
+    Trusted adapters always adapt unproxied objects.  If asked to
+    adapt any proxied objects, it will unproxy them and then 
+    security-proxy the resulting adapter unless the objects where not
+    security-proxied before.
 
-       Further trusted adapters always provide a location. If an adapter
-       itself does not provide ILocation it is wrapped within a location proxy
-       and it parent will be set:
+    Further this adapter factory sets the __parent__ attribute of locatable
+    object (ILocation) unless those objects do not provide their parent
+    itself.
 
-           security proxy > location proxy > adapter > object(s)
+    We account three different base use cases A, B and C (corresponding 
+    to def assertLocation()) each of them provided two variantions S and
+    N corresponding to class TrustedAdapterFactoryMixin).
 
-       If the adapter does provide ILocation and it's __parent__ is None,
-       we set the __parent__ only: 
-       
-           security proxy > adapter > object(s) 
+    Now, suppose have an object and proxy it:
 
-       Suppose we have an adapter factory:
+        >>> o = []
+        >>> p = ProxyFactory(o)
 
-         >>> class B(Location):
-         ...     def __init__(self, context):
-         ...         self.context = context
+    A. Unlocatable adatpers
 
-       Now, suppose have an object and proxy it:
+        >>> class A(object):
+        ...     def __init__(self, context):
+        ...         self.context = context
 
-         >>> o = []
-         >>> p = ProxyFactory(o)
+        >>> TA = TrustedAdapterFactory(A)
 
-       If we adapt it:
+    AS. Security-proxied:
 
-         >>> a = B(p)
+        >>> a = TA(p)
+        >>> a.__parent__
+        Traceback (most recent call last):
+        ...
+        AttributeError: 'A' object has no attribute '__parent__'
+        >>> type(a).__name__
+        '_Proxy'
 
-       the result is not a proxy:
+    AN. None-security-proxied:
 
-         >>> type(a).__name__
-         'B'
+        >>> a = TA(o)
+        >>> a.__parent__
+        Traceback (most recent call last):
+        ...
+        AttributeError: 'A' object has no attribute '__parent__'
+        >>> type(a).__name__
+        'A'
 
-       But the object it adapts still is:
+    B. Locatable, but parentless adapters
 
-         >>> type(a.context).__name__
-         '_Proxy'
+        >>> class B(Location):
+        ...     def __init__(self, context):
+        ...         self.context = context
 
-       Now, will we'll adapt our adapter factory to a trusted adapter factory:
 
-         >>> TB = TrustedAdapterFactory(B)
+        >>> TB = TrustedAdapterFactory(B)
 
-       and if we use it:
+    BS. Security-proxied:
 
-         >>> a = TB(p)
+        >>> a = TB(p)
+        >>> removeSecurityProxy(a.__parent__) is o
+        True
+        >>> type(a).__name__
+        '_Proxy'
 
-       then the adapter is proxied:
+    BS. None-security-proxied:
 
-         >>> type(a).__name__
-         '_Proxy'
+        >>> a = TB(o)
+        >>> a.__parent__ is o
+        True
+        >>> type(a).__name__
+        'B'
 
-       And the object proxied is not.  (We actually have to remove the
-       adapter to get to the adapted object in this case.)
+    C. Locatable and parentful adapter
 
-         >>> a = removeSecurityProxy(a)
-         >>> type(a.context).__name__
-         'list'
+        >>> marker = Location()
 
-       This works with multiple objects too:
+        >>> class C(Location):
+        ...     def __init__(self, context):
+        ...         self.context = context
+        ...         self.__parent__ = marker
 
-         >>> class M(Location):
-         ...     def __init__(self, *context):
-         ...         self.context = context
 
-         >>> TM = TrustedAdapterFactory(M)
+        >>> TC = TrustedAdapterFactory(C)
 
-         >>> o2 = []
-         >>> o3 = []
+    CS. Security-proxied:
 
-         >>> a = TM(p, o2, o3)
-         >>> type(a).__name__
-         '_Proxy'
-         >>> a = removeSecurityProxy(a)
-         >>> a.context[0] is o, a.context[1] is o2, a.context[2] is o3
-         (True, True, True)
+        >>> a = TC(p)
+        >>> removeSecurityProxy(a.__parent__) is marker
+        True
+        >>> type(a).__name__
+        '_Proxy'
 
-         >>> a = TM(p, ProxyFactory(o2), ProxyFactory(o3))
-         >>> type(a).__name__
-         '_Proxy'
-         >>> a = removeSecurityProxy(a)
-         >>> a.context[0] is o, a.context[1] is o2, a.context[2] is o3
-         (True, True, True)
+    CS. None-security-proxied:
 
-       The __parent__ will be always set to the first object unless the
-       adapter's parent is not None. This happens even if the adapter 
-       itself does not provide a location.
-       
-       A. None-locatable Adapters:
+        >>> a = TC(o)
+        >>> a.__parent__ is marker
+        True
+        >>> type(a).__name__
+        'C'
+    """
 
-         >>> class A(object):
-         ...     def __init__(self, context):
-         ...         self.context = context
+    def _customize(self, adapter, context):
+        if (ILocation.providedBy(adapter)
+            and adapter.__parent__ is None):
+                    adapter.__parent__ = context
+        return adapter
 
-         >>> TA = TrustedAdapterFactory(A)
-         >>> TA(o).__parent__ is o
-         True
 
-       B. Locatable, parentless Adapters:
 
-         >>> TB = TrustedAdapterFactory(B)
-         >>> TB(o).__parent__ is o
-         True
-         >>> removeSecurityProxy(TB(p)).__parent__ is o
-         True
+class LocatingTrustedAdapterFactory(TrustedAdapterFactoryMixin):
+    """Adapt an adapter factory to to provide trusted locatable adapters
 
-       C. Locatable, parentful Adapters:
+    Trusted adapters always adapt unproxied objects.  If asked to
+    adapt any proxied objects, it will unproxy them and then 
+    security-proxy the resulting adapter unless the objects where not
+    security-proxied before.
 
-         >>> class C(Location):
-         ...     def __init__(self, context):
-         ...         self.context = context
-         ...         self.__parent__ = context
+    Further locating trusted adapters always provide a location.
+    If an adapter itself does not provide ILocation it is wrapped 
+    within a location proxy and it parent will be set:
 
-         >>> TC = TrustedAdapterFactory(C)
-         >>> TC(o).__parent__ is o
-         True
-         >>> removeSecurityProxy(TC(p)).__parent__ is o
-         True
+        security proxy > location proxy > adapter > object(s)
 
-       The factory adapter has the __name__ and __module__ of the
-       factory it adapts:
+    If the adapter does provide ILocation and it's __parent__ is None,
+    we set the __parent__ only: 
+    
+        security proxy > adapter > object(s) 
 
-         >>> (TB.__module__, TB.__name__) == (B.__module__, B.__name__)
-         True
+    Now, suppose have an object and proxy it:
 
-       """
+        >>> o = []
+        >>> p = ProxyFactory(o)
 
-    def __init__(self, factory):
-        self.factory = factory
-        self.__name__ = factory.__name__
-        self.__module__ = factory.__module__
+    A. Unlocatable adatpers
 
-    def __call__(self, *args):
-        for arg in args:
-            if removeSecurityProxy(arg) is not arg:
-                args = map(removeSecurityProxy, args)
-                adapter = self.factory(*args)
-                return ProxyFactory(assertLocation(adapter, args[0]))
+        >>> class A(object):
+        ...     def __init__(self, context):
+        ...         self.context = context
 
-        adapter = self.factory(*args)
-        return assertLocation(adapter, args[0])
+        >>> TA = LocatingTrustedAdapterFactory(A)
 
+    AS. Security-proxied:
 
-class UntrustedAdapterFactory(object):
+        >>> a = TA(p)
+        >>> removeSecurityProxy(a.__parent__) is o
+        True
+        >>> type(a).__name__
+        '_Proxy'
+        >>> type(removeSecurityProxy(a)).__name__
+        'LocationProxy'
+        >>> from zope.proxy import removeAllProxies
+        >>> type(removeAllProxies(a)).__name__
+        'A'
+
+    AN. None-security-proxied:
+
+        >>> a = TA(o)
+        >>> a.__parent__ is o
+        True
+        >>> type(a).__name__
+        'LocationProxy'
+        >>> type(removeAllProxies(a)).__name__
+        'A'
+
+    B. Locatable, but parentless adapters
+
+        >>> class B(Location):
+        ...     def __init__(self, context):
+        ...         self.context = context
+
+
+        >>> TB = LocatingTrustedAdapterFactory(B)
+
+    BS. Security-proxied:
+
+        >>> a = TB(p)
+        >>> removeSecurityProxy(a.__parent__) is o
+        True
+        >>> type(a).__name__
+        '_Proxy'
+
+    BS. None-security-proxied:
+
+        >>> a = TB(o)
+        >>> a.__parent__ is o
+        True
+        >>> type(a).__name__
+        'B'
+
+    C. Locatable and parentful adapter
+
+        >>> marker = Location()
+
+        >>> class C(Location):
+        ...     def __init__(self, context):
+        ...         self.context = context
+        ...         self.__parent__ = marker
+
+
+        >>> TC = LocatingTrustedAdapterFactory(C)
+
+    CS. Security-proxied:
+
+        >>> a = TC(p)
+        >>> removeSecurityProxy(a.__parent__) is marker
+        True
+        >>> type(a).__name__
+        '_Proxy'
+
+    CS. None-security-proxied:
+
+        >>> a = TC(o)
+        >>> a.__parent__ is marker
+        True
+        >>> type(a).__name__
+        'C'
+    """
+
+    def _customize(self, adapter, context):
+        return assertLocation(adapter, context)
+
+
+class LocatingUntrustedAdapterFactory(object):
     """Adapt an adapter factory to provide locatable untrusted adapters
 
-       Untrusted adapters always adapt proxied objects. If any permission
-       other than zope.Public is required, untrusted adapters need a location
-       in order that the local authentication mechanism can be inovked correctly.
+    Untrusted adapters always adapt proxied objects. If any permission
+    other than zope.Public is required, untrusted adapters need a location
+    in order that the local authentication mechanism can be inovked
+    correctly.
 
-       If the adapter doesn't provide ILocation, we location proxy it and
-       set the parent:
-       
+    If the adapter does not provide ILocation, we location proxy it and
+    set the parent:
+    
         location proxy > adapter > security proxy > object(s) 
-       
-       If the adapter does provide ILocation and it's __parent__ is None,
-       we set the __parent__ only:
+    
+    If the adapter does provide ILocation and it's __parent__ is None,
+    we set the __parent__ only:
 
-         adapter > security proxy > object(s)
+        adapter > security proxy > object(s)
 
-       Now, suppose have an object and proxy it:
+    Now, suppose have an object and proxy it:
 
-         o = []
-         >>> o = []
-         >>> p = ProxyFactory(o)
+      o = []
+      >>> o = []
+      >>> p = ProxyFactory(o)
 
-       A. Adapters which do not provide ILocation get location-proxied
-       and theirs parent is set:
+    A. Adapters which do not provide ILocation get location-proxied
+    and theirs parent is set:
 
-         >>> class A(object):
-         ...     def __init__(self, context):
-         ...         self.context = context
+        >>> class A(object):
+        ...     def __init__(self, context):
+        ...         self.context = context
 
-         >>> UA = UntrustedAdapterFactory(A)
-         >>> a = UA(o)
+        >>> UA = LocatingUntrustedAdapterFactory(A)
+        >>> a = UA(o)
 
-         >>> ILocation.providedBy(a)
-         True
-         >>> a.__parent__ is o
-         True
-         >>> type(a).__name__
-         'LocationProxy'
+        >>> ILocation.providedBy(a)
+        True
+        >>> a.__parent__ is o
+        True
+        >>> type(a).__name__
+        'LocationProxy'
+        >>> from zope.proxy import removeAllProxies
+        >>> type(removeAllProxies(a)).__name__
+        'A'
 
-       B. Adapters which do provide ILocation get never location-proxied,
-       but theirs parent is also set unless their parent is
-       not None:
+    B. Adapters which do provide ILocation get never location-proxied,
+    but theirs parent is also set unless their parent is
+    not None:
 
-           >>> class B(Location):
-           ...     def __init__(self, context):
-           ...         self.context = context
+        >>> class B(Location):
+        ...     def __init__(self, context):
+        ...         self.context = context
 
-           >>> UB = UntrustedAdapterFactory(B)
-           >>> b = UB(o)
+        >>> UB = LocatingUntrustedAdapterFactory(B)
+        >>> b = UB(o)
 
-           >>> ILocation.providedBy(b)
-           True
-           >>> b.__parent__ is o
-           True
-           >>> type(b).__name__
-           'B'
+        >>> ILocation.providedBy(b)
+        True
+        >>> b.__parent__ is o
+        True
+        >>> type(b).__name__
+        'B'
 
-       C. In those cases where the parent is provided by the adapter itself,
-       nothing happens:
+    C. In those cases where the parent is provided by the adapter itself,
+    nothing happens:
 
-           >>> class C(Location):
-           ...     def __init__(self, context):
-           ...         self.context = context
-           ...         self.__parent__ = context
+        >>> class C(Location):
+        ...     def __init__(self, context):
+        ...         self.context = context
+        ...         self.__parent__ = context
 
-           >>> UC = UntrustedAdapterFactory(C)
-           >>> c = UC(o)
+        >>> UC = LocatingUntrustedAdapterFactory(C)
+        >>> c = UC(o)
 
-           >>> ILocation.providedBy(c)
-           True
-           >>> c.__parent__ is o
-           True
-           >>> type(c).__name__
-           'C'
+        >>> ILocation.providedBy(c)
+        True
+        >>> c.__parent__ is o
+        True
+        >>> type(c).__name__
+        'C'
 
-        The factory adapter has the __name__ and __module__ of the
-        factory it adapts:
+     The factory adapter has the __name__ and __module__ of the
+     factory it adapts:
 
-            >>> (UB.__module__, UB.__name__) == (B.__module__, B.__name__)
-            True
-
+         >>> (UB.__module__, UB.__name__) == (B.__module__, B.__name__)
+         True
     """
 
     def __init__(self, factory):



More information about the Zope3-Checkins mailing list