[Zope3-checkins] CVS: Zope3/src/zope/app/traversing/tests - test_acquire.py:1.8 test_conveniencefunctions.py:1.20 test_physicallocationadapters.py:1.14 test_traverser.py:1.13

Jim Fulton jim at zope.com
Sun Sep 21 13:31:45 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/traversing/tests
In directory cvs.zope.org:/tmp/cvs-serv12774/src/zope/app/traversing/tests

Modified Files:
	test_acquire.py test_conveniencefunctions.py 
	test_physicallocationadapters.py test_traverser.py 
Log Message:
No-longer use context wrappers.


=== Zope3/src/zope/app/traversing/tests/test_acquire.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/traversing/tests/test_acquire.py:1.7	Sun Jun  1 11:59:38 2003
+++ Zope3/src/zope/app/traversing/tests/test_acquire.py	Sun Sep 21 13:31:14 2003
@@ -22,7 +22,6 @@
 from zope.app.interfaces.traversing import ITraversable
 from zope.app.traversing.adapters import DefaultTraversable
 from zope.component.adapter import provideAdapter
-from zope.app.context import ContextWrapper
 from zope.app.traversing.namespace import acquire
 from zope.exceptions import NotFoundError
 
@@ -37,13 +36,13 @@
 
         a = C('a')
         a.a1 = C('a1')
-        a.a2 = C('a2')
-        a.a2.a21 = C('a21')
-        a.a2.a21.a211 = C('a211')
+        a.a2 = C('a2'); a.a2.__parent__ = a
+        a.a2.a21 = C('a21'); a.a2.a21.__parent__ = a.a2
+        a.a2.a21.a211 = C('a211'); a.a2.a21.a211.__parent__ = a.a2.a21
 
-        a2 = ContextWrapper(a.a2, a)
-        a21 = ContextWrapper(a.a2.a21, a2)
-        a211 = ContextWrapper(a.a2.a21.a211, a21)
+        a2 = a.a2
+        a21 = a.a2.a21
+        a211 = a.a2.a21.a211
 
         acquired = acquire('a1', (), 'a1;acquire', a211, None)
 


=== Zope3/src/zope/app/traversing/tests/test_conveniencefunctions.py 1.19 => 1.20 ===
--- Zope3/src/zope/app/traversing/tests/test_conveniencefunctions.py:1.19	Fri Jun 13 13:41:21 2003
+++ Zope3/src/zope/app/traversing/tests/test_conveniencefunctions.py	Sun Sep 21 13:31:14 2003
@@ -18,8 +18,6 @@
 from unittest import TestCase, main, makeSuite
 from zope.interface import directlyProvides
 from zope.app.services.tests.placefulsetup import PlacefulSetup
-from zope.app.context import ContextWrapper
-from zope.context import isWrapper
 from zope.app.traversing.adapters import Traverser
 from zope.component import getService
 from zope.app.services.servicenames import Adapters
@@ -28,15 +26,18 @@
 
 from zope.app.interfaces.traversing import IPhysicallyLocatable
 from zope.app.interfaces.traversing import IContainmentRoot
-from zope.app.traversing.adapters import WrapperPhysicallyLocatable
+from zope.app.location import LocationPhysicallyLocatable
 from zope.app.traversing.adapters import RootPhysicallyLocatable
 
 from zope.security.proxy import Proxy
 from zope.security.checker import selectChecker
 
 from zope.exceptions import NotFoundError
+from zope.app.container.contained import contained
 
 class C:
+    __parent__ = None
+    __name__ = None
     def __init__(self, name):
         self.name = name
 
@@ -55,11 +56,11 @@
         item = C('item')
 
         self.root = root  # root is not usually wrapped
-        self.folder = ContextWrapper(folder, self.root,   name='folder')
-        self.item =   ContextWrapper(item,   self.folder, name='item')
+        self.folder = contained(folder, self.root,   name='folder')
+        self.item =   contained(item,   self.folder, name='item')
         self.unwrapped_item = item
-        self.broken_chain_folder = ContextWrapper(folder, None)
-        self.broken_chain_item = ContextWrapper(item,
+        self.broken_chain_folder = contained(folder, None)
+        self.broken_chain_item = contained(item,
                                     self.broken_chain_folder,
                                     name='item'
                                     )
@@ -72,7 +73,7 @@
         getService(None, Adapters).provideAdapter(
               None, ITraversable, DefaultTraversable)
         getService(None, Adapters).provideAdapter(
-              None, IPhysicallyLocatable, WrapperPhysicallyLocatable)
+              None, IPhysicallyLocatable, LocationPhysicallyLocatable)
         getService(None, Adapters).provideAdapter(
               IContainmentRoot, IPhysicallyLocatable, RootPhysicallyLocatable)
 
@@ -105,7 +106,7 @@
             traverseName(self.item, '..'),
             self.tr.traverse('/folder')
             )
-        self.assert_(isWrapper(traverseName(self.folder, 'item')))
+
         # XXX test that ++names++ and @@names work too
 
     def testTraverseNameBadValue(self):
@@ -133,14 +134,6 @@
             'item'
             )
 
-    def testGetNameFromUnwrapped(self):
-        from zope.app.traversing import getName
-        self.assertRaises(
-            TypeError,
-            getName,
-            self.unwrapped_item
-            )
-
     def testGetParent(self):
         from zope.app.traversing import getParent
         self.assertEqual(
@@ -148,14 +141,6 @@
             self.folder
             )
 
-    def testGetParentOtherContext(self):
-        from zope.app.traversing import getParent
-        item = ContextWrapper(self.item, self.root, name='item')
-        self.assertEqual(
-            getParent(item),
-            self.folder
-            )
-
     def testGetParentFromRoot(self):
         from zope.app.traversing import getParent
         self.assertEqual(
@@ -192,14 +177,6 @@
             TypeError,
             getParents,
             self.broken_chain_item
-            )
-
-    def testGetParentsFromUnwrapped(self):
-        from zope.app.traversing import getParents
-        self.assertRaises(
-            TypeError,
-            getParents,
-            self.unwrapped_item
             )
 
     def testGetParentFromUnwrapped(self):


=== Zope3/src/zope/app/traversing/tests/test_physicallocationadapters.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/traversing/tests/test_physicallocationadapters.py:1.13	Fri Aug  8 14:07:11 2003
+++ Zope3/src/zope/app/traversing/tests/test_physicallocationadapters.py	Sun Sep 21 13:31:14 2003
@@ -23,9 +23,9 @@
 
 from zope.app.interfaces.traversing import IContainmentRoot
 from zope.app.interfaces.traversing import IPhysicallyLocatable
-from zope.app.traversing.adapters import WrapperPhysicallyLocatable
+from zope.app.location import LocationPhysicallyLocatable
 from zope.app.traversing.adapters import RootPhysicallyLocatable
-from zope.app.context import ContextWrapper
+from zope.app.container.contained import contained
 
 class Root:
     implements(IContainmentRoot)
@@ -36,25 +36,20 @@
 class Test(PlacelessSetup, TestCase):
 
     def test(self):
-        provideAdapter(None, IPhysicallyLocatable, WrapperPhysicallyLocatable)
+        provideAdapter(None, IPhysicallyLocatable, LocationPhysicallyLocatable)
         provideAdapter(IContainmentRoot, IPhysicallyLocatable,
                        RootPhysicallyLocatable)
 
         root = Root()
-        f1 = ContextWrapper(C(), root, name='f1')
-        f2 = ContextWrapper(C(),   f1, name='f2')
-        f3 = ContextWrapper(C(),   f2, name='f3')
+        f1 = contained(C(), root, name='f1')
+        f2 = contained(C(),   f1, name='f2')
+        f3 = contained(C(),   f2, name='f3')
 
         adapter = getAdapter(f3, IPhysicallyLocatable)
 
         self.assertEqual(adapter.getPath(), '/f1/f2/f3')
         self.assertEqual(adapter.getName(), 'f3')
         self.assertEqual(adapter.getRoot(), root)
-
-        adapter = getAdapter(C(), IPhysicallyLocatable)
-        self.assertRaises(TypeError, adapter.getPath)
-        self.assertRaises(TypeError, adapter.getName)
-        self.assertRaises(TypeError, adapter.getRoot)
 
 
 def test_suite():


=== Zope3/src/zope/app/traversing/tests/test_traverser.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/traversing/tests/test_traverser.py:1.12	Sat Jun  7 02:54:24 2003
+++ Zope3/src/zope/app/traversing/tests/test_traverser.py	Sun Sep 21 13:31:14 2003
@@ -27,10 +27,10 @@
 
 from zope.app.interfaces.traversing import IPhysicallyLocatable
 from zope.app.interfaces.traversing import IContainmentRoot
-from zope.app.traversing.adapters import WrapperPhysicallyLocatable
+from zope.app.location import LocationPhysicallyLocatable
 from zope.app.traversing.adapters import RootPhysicallyLocatable
+from zope.app.container.contained import contained
 
-from zope.app.context import ContextWrapper
 from zope.exceptions import NotFoundError, Unauthorized
 from zope.component import getService
 from zope.app.services.servicenames import Adapters
@@ -39,8 +39,9 @@
 from zope.security.checker \
     import ProxyFactory, defineChecker, CheckerPublic, Checker
 from zope.security.management import newSecurityManager
+from zope.app.container.contained import Contained, contained
 
-class C:
+class C(Contained):
     def __init__(self, name):
         self.name = name
 
@@ -50,8 +51,8 @@
         PlacefulSetup.setUp(self)
         # Build up a wrapper chain
         self.root =   C('root')
-        self.folder = ContextWrapper(C('folder'), self.root,   name='folder')
-        self.item =   ContextWrapper(C('item'),   self.folder, name='item')
+        self.folder = contained(C('folder'), self.root,   name='folder')
+        self.item =   contained(C('item'),   self.folder, name='item')
         self.tr = Traverser(self.item)
 
     def testImplementsITraverser(self):
@@ -85,14 +86,14 @@
         getService(None, Adapters).provideAdapter(
               None, ITraversable, DefaultTraversable)
         getService(None, Adapters).provideAdapter(
-              None, IPhysicallyLocatable, WrapperPhysicallyLocatable)
+              None, IPhysicallyLocatable, LocationPhysicallyLocatable)
         getService(None, Adapters).provideAdapter(
               IContainmentRoot, IPhysicallyLocatable, RootPhysicallyLocatable)
 
         self.root = root = C('root')
         directlyProvides(self.root, IContainmentRoot)
-        self.folder = folder = C('folder')
-        self.item = item = C('item')
+        self.folder = folder = contained(C('folder'), root, 'folder')
+        self.item = item = contained(C('item'), folder, 'item')
 
         root.folder = folder
         folder.item = item
@@ -129,9 +130,6 @@
 
         self.assertEquals(tr.traverse('/folder/../folder/./item'),
             item)
-        self.assertEquals(tr.traverse(
-            '/../folder/../../folder/item'), item)
-        self.assertEquals(tr.traverse('../../folder/item'), item)
 
     def testNotFoundDefault(self):
         self.assertEquals(self.tr.traverse('foo', 'notFound'),
@@ -159,14 +157,14 @@
         getService(None,Adapters).provideAdapter(
              None, ITraversable, DefaultTraversable)
         getService(None, Adapters).provideAdapter(
-              None, IPhysicallyLocatable, WrapperPhysicallyLocatable)
+              None, IPhysicallyLocatable, LocationPhysicallyLocatable)
         getService(None, Adapters).provideAdapter(
               IContainmentRoot, IPhysicallyLocatable, RootPhysicallyLocatable)
 
         self.root = root = C('root')
         directlyProvides(root, IContainmentRoot)
-        self.folder = folder = C('folder')
-        self.item = item = C('item')
+        self.folder = folder = contained(C('folder'), root, 'folder')
+        self.item = item = contained(C('item'), folder, 'item')
 
         root.folder = folder
         folder.item = item




More information about the Zope3-Checkins mailing list