[Zope3-checkins] SVN: Zope3/branches/dominik-locatableadapters/src/zope/app/ revert to the first implementation concept:

Dominik Huber dominik.huber at projekt01.ch
Wed Apr 20 09:55:55 EDT 2005


Log message for revision 30059:
  revert to the first implementation concept:
  
  trusted adapters provide always a location.
  
  untrusted adapters provide a location unless
  its factories are public.
  
  if an adapter does not provide ILocation itself
  it gets location-proxied. such an adapter is
  not directly pickable because location proxies
  are not pickable. if you use pickalbe adapters
  they should provide ILocation.

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/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 13:14:02 UTC (rev 30058)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/component/metaconfigure.py	2005-04-20 13:55:54 UTC (rev 30059)
@@ -179,18 +179,15 @@
         factory = _protectedFactory(factory, checker)
 
     # 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)
+    if trusted:
+        # trusted adapters that requires dedicated permission all the time
+        factory = LocatingTrustedAdapterFactory(factory)
 
+    elif permission is not None and permission is not CheckerPublic:
+        # untrusted adapters that requires any dedicated permission
+        factory = LocatingUntrustedAdapterFactory(factory)  
+
+
     _context.action(
         discriminator = ('adapter', for_, provides, name),
         callable = handler,

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 13:14:02 UTC (rev 30058)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/component/tests/test_directives.py	2005-04-20 13:55:54 UTC (rev 30059)
@@ -343,9 +343,11 @@
             '''
             )))
 
-        # With an unproxied object, business as usual
+        # With an unproxied object, a location proxied adapter is returned
         ob = Content()
-        self.assertEqual(type(I1(ob)), type(A1()))
+        self.assertEqual(type(I1(ob)).__name__, 'LocationProxy')
+        from zope.proxy import removeAllProxies
+        self.assertEqual(type(removeAllProxies(I1(ob))).__name__, 'A1')
 
         # Now with a proxied object:
         from zope.security.checker import ProxyFactory
@@ -359,6 +361,7 @@
         # around an unproxied object:
         from zope.security.proxy import removeSecurityProxy
         a = removeSecurityProxy(a)
+        self.assertEqual(type(a).__name__, 'LocationProxy')
         self.assert_(a.context[0] is ob)
         
         
@@ -492,7 +495,6 @@
               factory="zope.app.component.tests.adapter.A3"
               provides="zope.app.component.tests.adapter.I3"
               for=""
-              trusted="True"
               />
             '''
             )))

Modified: Zope3/branches/dominik-locatableadapters/src/zope/app/keyreference/persistent.py
===================================================================
--- Zope3/branches/dominik-locatableadapters/src/zope/app/keyreference/persistent.py	2005-04-20 13:14:02 UTC (rev 30058)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/keyreference/persistent.py	2005-04-20 13:55:54 UTC (rev 30059)
@@ -24,8 +24,9 @@
 import zope.interface
 
 import zope.app.keyreference.interfaces
+from zope.app.location import Location
 
-class KeyReferenceToPersistent(object):
+class KeyReferenceToPersistent(Location):
     """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 13:14:02 UTC (rev 30058)
+++ Zope3/branches/dominik-locatableadapters/src/zope/app/security/adapter.py	2005-04-20 13:55:54 UTC (rev 30059)
@@ -238,6 +238,8 @@
         return adapter
 
 
+# BBB: The trusted adapter factory is replaced by the locating trusted adapter
+# factory
 class TrustedAdapterFactory(TrustedAdapterFactoryMixin):
     """Adapt an adapter factory to to provide trusted adapters
 



More information about the Zope3-Checkins mailing list