[z3-checkins] r21808 - in z3/Five/trunk: . site site/tests tests

philikon at codespeak.net philikon at codespeak.net
Sun Jan 8 07:30:48 CET 2006


Author: philikon
Date: Sun Jan  8 07:30:26 2006
New Revision: 21808

Modified:
   z3/Five/trunk/CHANGES.txt
   z3/Five/trunk/site/localsite.py
   z3/Five/trunk/site/tests/sitemanager.txt
   z3/Five/trunk/tests/adapters.py
Log:
Merge r21806 from 1.3 branch (and add changes entry):
  Fix http://codespeak.net/pipermail/z3-five/2006q1/001003.html.  Sorry, this
  was my bad.


Modified: z3/Five/trunk/CHANGES.txt
==============================================================================
--- z3/Five/trunk/CHANGES.txt	(original)
+++ z3/Five/trunk/CHANGES.txt	Sun Jan  8 07:30:26 2006
@@ -17,6 +17,15 @@
   NOTE: Anyone who copied the Five site.zcml to their
   $INSTANCE_HOME/etc/ directory is going to need to update it.
 
+Five 1.3.1 (2006-01-08)
+=======================
+
+Bugfixes
+--------
+
+* Fix an adapter look-up bug in the local site implementation that was
+  due to an oversight during the port to Zope 3.2.
+
 Five 1.3 (2006-01-07)
 =====================
 

Modified: z3/Five/trunk/site/localsite.py
==============================================================================
--- z3/Five/trunk/site/localsite.py	(original)
+++ z3/Five/trunk/site/localsite.py	Sun Jan  8 07:30:26 2006
@@ -111,7 +111,10 @@
 
     @property
     def adapters(self):
-        return getGlobalSiteManager().adapters #XXX wrong
+        next = self.next
+        if next is None:
+            next = getGlobalSiteManager()
+        return next.adapters
 
     @property
     def utilities(self):
@@ -124,7 +127,10 @@
         return self.adapters.queryMultiAdapter(objects, interface, name, default)
 
     def getAdapters(self, objects, provided):
-        return self.adapters.getAdapters(objects, provided)
+        next = self.next
+        if next is None:
+            next = getGlobalSiteManager()
+        return next.getAdapters(objects, provided)
 
     def subscribers(self, required, provided):
         return self.adapters.subscribers(required, provided)

Modified: z3/Five/trunk/site/tests/sitemanager.txt
==============================================================================
--- z3/Five/trunk/site/tests/sitemanager.txt	(original)
+++ z3/Five/trunk/site/tests/sitemanager.txt	Sun Jan  8 07:30:26 2006
@@ -85,9 +85,27 @@
   True
 
 The methods on registering and looking up utilities are covered by the
-utility tests in depth.  The methods on adapter look up are indirectly
-covered in the functional test; view look up, for example, is adapter
-look up.
+utility tests in depth.
+
+We test some adapter look-up here.  It is also indirectly covered in
+the functional test; view look up, for example, is adapter look up.
+
+First we provide an adapter:
+
+  >>> from Products.Five.tests.adapters import Adaptable, Adapter, IAdapted
+  >>> import zope.component
+  >>> zope.component.provideAdapter(Adapter)
+
+Now let's check for a simple adaption:
+
+  >>> adaptable = Adaptable()
+  >>> IAdapted(adaptable) #doctest: +ELLIPSIS
+  <Products.Five.tests.adapters.Adapter instance at ...>
+
+Let's get all the adapters for ``adaptable``:
+
+  >>> zapi.getAdapters((adaptable,), IAdapted) #doctest: +ELLIPSIS
+  [(u'', <Products.Five.tests.adapters.Adapter instance at ...>)]
 
 
 Nesting sites
@@ -118,6 +136,10 @@
   >>> getNextSiteManager(subsite.getSiteManager()).context == dummysite
   True
 
+The adapters is registry is passed through to the global one:
+
+  >>> subsite.getSiteManager().adapters is zapi.getGlobalSiteManager().adapters
+  True
 
 Finally, some clean up:
 

Modified: z3/Five/trunk/tests/adapters.py
==============================================================================
--- z3/Five/trunk/tests/adapters.py	(original)
+++ z3/Five/trunk/tests/adapters.py	Sun Jan  8 07:30:26 2006
@@ -16,6 +16,7 @@
 $Id$
 """
 from zope.interface import implements, Interface
+from zope.component import adapts
 
 class IAdaptable(Interface):
     """This is a Zope 3 interface.
@@ -49,6 +50,7 @@
 
 class Adapter:
     implements(IAdapted)
+    adapts(IAdaptable)
 
     def __init__(self, context):
         self.context = context


More information about the z3-checkins mailing list