[Zope-Checkins] SVN: Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/ Add another test that tests acquisition wrappers with containers that have __parent__.

Philipp von Weitershausen philikon at philikon.de
Mon Nov 20 19:29:07 EST 2006


Log message for revision 71223:
  Add another test that tests acquisition wrappers with containers that have __parent__.
  

Changed:
  _U  Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/
  U   Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py

-=-

Property changes on: Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition
___________________________________________________________________
Name: svk:merge
   - bfa16f6a-5b7b-4684-983a-15b8a78f95a3:/local/Acquisition:3244
   + bfa16f6a-5b7b-4684-983a-15b8a78f95a3:/local/Acquisition:3245

Modified: Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py
===================================================================
--- Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py	2006-11-21 00:28:54 UTC (rev 71222)
+++ Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py	2006-11-21 00:29:06 UTC (rev 71223)
@@ -1794,7 +1794,7 @@
       >>> Acquisition.aq_acquire(x, 'bar')
       3.145
 
-    Note that also the (implicit) acquisition wrapper has a __parent__
+    Note that also the (explicit) acquisition wrapper has a __parent__
     pointer, which is automatically computed from the acquisition
     container (it's identical to aq_parent):
 
@@ -1822,6 +1822,74 @@
     TODO aq_parent, aq_chain
     """
 
+def test_implicit_wrapper_has_nonwrapper_as_aq_parent():
+    """Let's do this the other way around: The root and the
+    intermediate parent is an object that doesn't support acquisition,
+
+      >>> y = ECLocation()
+      >>> z = Location()
+      >>> y.__parent__ = z
+      >>> y.foo = 42
+      >>> z.foo = 43  # this should not be found
+      >>> z.bar = 3.145
+
+    only the outmost object does:
+
+      >>> class Impl(Acquisition.Implicit):
+      ...     hello = 'world'
+      >>> x = Impl().__of__(y)
+
+    Again, acquiring objects work as usual:
+
+      >>> Acquisition.aq_acquire(x, 'hello')
+      'world'
+      >>> Acquisition.aq_acquire(x, 'foo')
+      42
+      >>> Acquisition.aq_acquire(x, 'bar')
+      3.145
+
+    Because the outmost object, ``x``, is wrapped in an implicit
+    acquisition wrapper, we can also use direct attribute access:
+
+      >>> x.hello
+      'world'
+      >>> x.foo
+      42
+      >>> x.bar
+      3.145
+
+    TODO aq_parent, aq_chain
+    """
+
+def test_explicit_wrapper_has_nonwrapper_as_aq_parent():
+    """Let's do this the other way around: The root and the
+    intermediate parent is an object that doesn't support acquisition,
+
+      >>> y = ECLocation()
+      >>> z = Location()
+      >>> y.__parent__ = z
+      >>> y.foo = 42
+      >>> z.foo = 43  # this should not be found
+      >>> z.bar = 3.145
+
+    only the outmost object does:
+
+      >>> class Expl(Acquisition.Explicit):
+      ...     hello = 'world'
+      >>> x = Expl().__of__(y)
+
+    Again, acquiring objects work as usual:
+
+      >>> Acquisition.aq_acquire(x, 'hello')
+      'world'
+      >>> Acquisition.aq_acquire(x, 'foo')
+      42
+      >>> Acquisition.aq_acquire(x, 'bar')
+      3.145
+
+    TODO aq_parent, aq_chain
+    """
+
 import unittest
 from zope.testing.doctest import DocTestSuite
 



More information about the Zope-Checkins mailing list