[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/publisher/ remove dependency on zope.app.zapi

Fred L. Drake, Jr. fdrake at gmail.com
Sun Mar 25 06:14:24 EDT 2007


Log message for revision 73579:
  remove dependency on zope.app.zapi

Changed:
  U   Zope3/trunk/src/zope/app/publisher/browser/fields.py
  U   Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
  U   Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
  U   Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
  U   Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py
  U   Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py
  U   Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py

-=-
Modified: Zope3/trunk/src/zope/app/publisher/browser/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/fields.py	2007-03-25 10:12:57 UTC (rev 73578)
+++ Zope3/trunk/src/zope/app/publisher/browser/fields.py	2007-03-25 10:14:23 UTC (rev 73579)
@@ -17,6 +17,7 @@
 """
 __docformat__ = 'restructuredtext'
 
+import zope.component
 import zope.schema
 from zope.component.interfaces import ComponentLookupError
 from zope.configuration.exceptions import ConfigurationError
@@ -24,9 +25,7 @@
 from zope.interface.interfaces import IInterface
 from zope.app.publisher.interfaces.browser import IMenuItemType
 
-from zope.app import zapi
 
-
 class MenuField(GlobalObject):
     r"""This fields represents a menu (item type).
 
@@ -89,7 +88,7 @@
         name = str(u.strip())
 
         try:
-            value = zapi.queryUtility(IMenuItemType, name)
+            value = zope.component.queryUtility(IMenuItemType, name)
         except ComponentLookupError:
             # The component architecture is not up and running.
             pass

Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2007-03-25 10:12:57 UTC (rev 73578)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2007-03-25 10:14:23 UTC (rev 73579)
@@ -18,6 +18,7 @@
 __docformat__ = 'restructuredtext'
 
 import warnings
+from zope import component
 from zope.component.interfaces import IDefaultViewName
 from zope.component.interface import provideInterface
 from zope.component.zcml import handler
@@ -27,8 +28,6 @@
 from zope.publisher.interfaces.browser import IBrowserRequest, IDefaultSkin
 from zope.publisher.interfaces.browser import IBrowserSkinType
 
-from zope.app import zapi
-
 # referred to through ZCML
 from zope.app.publisher.browser.resourcemeta import resource
 from zope.app.publisher.browser.resourcemeta import resourceDirectory
@@ -368,14 +367,14 @@
 
     >>> ztapi.provideUtility(IBrowserSkinType, Skin1, 'Skin1')
     >>> setDefaultSkin('Skin1')
-    >>> adapters = zapi.getSiteManager().adapters
+    >>> adapters = component.getSiteManager().adapters
 
 	Lookup the default skin for a request that has the
 
     >>> adapters.lookup((IBrowserRequest,), IDefaultSkin, '') is Skin1
     True
     """
-    skin = zapi.getUtility(IBrowserSkinType, name)
+    skin = component.getUtility(IBrowserSkinType, name)
     handler('registerAdapter',
             skin, (IBrowserRequest,), IDefaultSkin, '', info),
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py	2007-03-25 10:12:57 UTC (rev 73578)
+++ Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py	2007-03-25 10:14:23 UTC (rev 73579)
@@ -24,8 +24,6 @@
 from zope.security.checker import CheckerPublic, NamesChecker
 from zope.component.zcml import handler
 
-from zope.app import zapi
-
 from fileresource import FileResourceFactory, ImageResourceFactory
 from pagetemplateresource import PageTemplateResourceFactory
 from directoryresource import DirectoryResourceFactory

Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py	2007-03-25 10:12:57 UTC (rev 73578)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py	2007-03-25 10:14:23 UTC (rev 73579)
@@ -19,6 +19,7 @@
 import unittest
 from cStringIO import StringIO
 
+from zope import component
 from zope.interface import Interface, implements, directlyProvides, providedBy
 
 import zope.security.management
@@ -37,7 +38,6 @@
 from zope.traversing.interfaces import ITraversable
 
 import zope.app.publisher.browser
-from zope.app import zapi
 from zope.app.component.tests.views import IC, V1, VZMI, R1, IV
 from zope.app.publisher.browser.fileresource import FileResource
 from zope.app.publisher.browser.i18nfileresource import I18nFileResource
@@ -124,8 +124,9 @@
         ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
 
     def testPage(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template % (
             '''
@@ -139,12 +140,13 @@
             '''
             )))
 
-        v = zapi.queryMultiAdapter((ob, request), name='test')
+        v = component.queryMultiAdapter((ob, request), name='test')
         self.assert_(issubclass(v.__class__, V1))
 
     def testPageWithClassWithMenu(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
         testtemplate = os.path.join(tests_path, 'testfiles', 'test.pt')
                          
 
@@ -166,13 +168,14 @@
         menuItem = getFirstMenuItem('test_menu', ob, TestRequest())
         self.assertEqual(menuItem["title"], "Test View")
         self.assertEqual(menuItem["action"], "@@test")
-        v = zapi.queryMultiAdapter((ob, request), name='test')
+        v = component.queryMultiAdapter((ob, request), name='test')
         self.assertEqual(v(), "<html><body><p>test</p></body></html>\n")
 
 
     def testPageWithTemplateWithMenu(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
         testtemplate = os.path.join(tests_path, 'testfiles', 'test.pt')
                          
         xmlconfig(StringIO(template % (
@@ -193,13 +196,14 @@
         menuItem = getFirstMenuItem('test_menu', ob, TestRequest())
         self.assertEqual(menuItem["title"], "Test View")
         self.assertEqual(menuItem["action"], "@@test")
-        v = zapi.queryMultiAdapter((ob, request), name='test')
+        v = component.queryMultiAdapter((ob, request), name='test')
         self.assertEqual(v(), "<html><body><p>test</p></body></html>\n")
 
 
     def testPageInPagesWithTemplateWithMenu(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
         testtemplate = os.path.join(tests_path, 'testfiles', 'test.pt')
 
         xmlconfig(StringIO(template % (
@@ -222,13 +226,14 @@
         menuItem = getFirstMenuItem('test_menu', ob, TestRequest())
         self.assertEqual(menuItem["title"], "Test View")
         self.assertEqual(menuItem["action"], "@@test")
-        v = zapi.queryMultiAdapter((ob, request), name='test')
+        v = component.queryMultiAdapter((ob, request), name='test')
         self.assertEqual(v(), "<html><body><p>test</p></body></html>\n")
 
 
     def testPageInPagesWithClassWithMenu(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
         testtemplate = os.path.join(tests_path, 'testfiles', 'test.pt')
                          
 
@@ -253,12 +258,12 @@
         menuItem = getFirstMenuItem('test_menu', ob, TestRequest())
         self.assertEqual(menuItem["title"], "Test View")
         self.assertEqual(menuItem["action"], "@@test")
-        v = zapi.queryMultiAdapter((ob, request), name='test')
+        v = component.queryMultiAdapter((ob, request), name='test')
         self.assertEqual(v(), "<html><body><p>test</p></body></html>\n")
 
     def testDefaultView(self):
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), IDefaultViewName),
+            component.queryMultiAdapter((ob, request), IDefaultViewName),
             None)
 
         xmlconfig(StringIO(template % (
@@ -269,7 +274,9 @@
             '''
             )))
 
-        self.assertEqual(zapi.getDefaultViewName(ob, request), 'test')
+        self.assertEqual(
+            zope.app.publisher.browser.getDefaultViewName(ob, request),
+            'test')
 
     def testDefaultViewWithLayer(self):
         class FakeRequest(TestRequest):
@@ -277,7 +284,7 @@
         request2 = FakeRequest()
 
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request2), IDefaultViewName),
+            component.queryMultiAdapter((ob, request2), IDefaultViewName),
             None)
 
         xmlconfig(StringIO(template % (
@@ -295,13 +302,17 @@
             '''
             )))
 
-        self.assertEqual(zapi.getDefaultViewName(ob, request2), 'test2')
-        self.assertEqual(zapi.getDefaultViewName(ob, request), 'test')
+        self.assertEqual(
+            zope.app.publisher.browser.getDefaultViewName(ob, request2),
+            'test2')
+        self.assertEqual(
+            zope.app.publisher.browser.getDefaultViewName(ob, request),
+            'test')
 
 
     def testSkinResource(self):
         self.assertEqual(
-            zapi.queryAdapter(Request(IV), name='test'), None)
+            component.queryAdapter(Request(IV), name='test'), None)
 
         xmlconfig(StringIO(template % (
             '''
@@ -319,15 +330,17 @@
             )))
 
         self.assertEqual(
-            zapi.queryAdapter(request, name='test').__class__, R1)
+            component.queryAdapter(request, name='test').__class__, R1)
         self.assertEqual(
-            zapi.queryAdapter(TestRequest(skin=ITestSkin), name='test').__class__,
+            component.queryAdapter(
+                TestRequest(skin=ITestSkin), name='test').__class__,
             RZMI)
 
     def testDefaultSkin(self):
         request = TestRequest()
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         XMLConfig('meta.zcml', zope.app.component)()        
         xmlconfig(StringIO(template % (
@@ -358,16 +371,17 @@
             )))
 
         # Simulate Zope Publication behavior in beforeTraversal()
-        adapters = zapi.getSiteManager().adapters
+        adapters = component.getSiteManager().adapters
         skin = adapters.lookup((providedBy(request),), IDefaultSkin, '')
         directlyProvides(request, skin)
 
-        v = zapi.queryMultiAdapter((ob, request), name='test')
+        v = component.queryMultiAdapter((ob, request), name='test')
         self.assert_(issubclass(v.__class__, VZMI))
 
     def testSkinPage(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template % (
             '''
@@ -388,13 +402,14 @@
             '''
             )))
 
-        v = zapi.queryMultiAdapter((ob, request), name='test')
+        v = component.queryMultiAdapter((ob, request), name='test')
         self.assert_(issubclass(v.__class__, V1))
-        v = zapi.queryMultiAdapter((ob, TestRequest(skin=ITestSkin)), name='test')
+        v = component.queryMultiAdapter(
+            (ob, TestRequest(skin=ITestSkin)), name='test')
         self.assert_(issubclass(v.__class__, VZMI))
 
     def testI18nResource(self):
-        self.assertEqual(zapi.queryAdapter(request, name='test'), None)
+        self.assertEqual(component.queryAdapter(request, name='test'), None)
 
         path1 = os.path.join(tests_path, 'testfiles', 'test.pt')
         path2 = os.path.join(tests_path, 'testfiles', 'test2.pt')
@@ -408,9 +423,9 @@
             ''' % (path1, path2)
             )))
 
-        v = zapi.getAdapter(request, name='test')
+        v = component.getAdapter(request, name='test')
         self.assertEqual(
-            zapi.queryAdapter(request, name='test').__class__,
+            component.queryAdapter(request, name='test').__class__,
             I18nFileResource)
         self.assertEqual(v._testData('en'), open(path1, 'rb').read())
         self.assertEqual(v._testData('fr'), open(path2, 'rb').read())
@@ -450,7 +465,7 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='test')
+        v = component.getMultiAdapter((ob, request), name='test')
         v = ProxyFactory(v)
         self.assertEqual(v.index(), 'V1 here')
         self.assertRaises(Exception, getattr, v, 'action')
@@ -468,7 +483,7 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='test')
+        v = component.getMultiAdapter((ob, request), name='test')
         v = ProxyFactory(v)
         self.assertEqual(v.action(), 'done')
         self.assertEqual(v.action2(), 'done')
@@ -488,7 +503,7 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='test')
+        v = component.getMultiAdapter((ob, request), name='test')
         v = ProxyFactory(v)
         page = v.publishTraverse(request, 'index.html')
         self.assertEqual(page(), 'done')
@@ -509,7 +524,7 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='test')
+        v = component.getMultiAdapter((ob, request), name='test')
         self.assertEqual(v.index(), 'V1 here')
         self.assertEqual(v.action(), 'done')
 
@@ -527,7 +542,7 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='test')
+        v = component.getMultiAdapter((ob, request), name='test')
         self.assertEqual(v.index(), 'V1 here')
         self.assertEqual(v.action(), 'done')
 
@@ -545,7 +560,7 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='test')
+        v = component.getMultiAdapter((ob, request), name='test')
         self.assertEqual(v.index(), v)
         self.assert_(IBrowserPublisher.providedBy(v))
 
@@ -566,8 +581,9 @@
 
 
     def testPageViews(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
         test3 = os.path.join(tests_path, 'testfiles', 'test3.pt')
 
         xmlconfig(StringIO(template %
@@ -585,16 +601,17 @@
             ''' % test3
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='index.html')
+        v = component.getMultiAdapter((ob, request), name='index.html')
         self.assertEqual(v(), 'V1 here')
-        v = zapi.getMultiAdapter((ob, request), name='action.html')
+        v = component.getMultiAdapter((ob, request), name='action.html')
         self.assertEqual(v(), 'done')
-        v = zapi.getMultiAdapter((ob, request), name='test.html')
+        v = component.getMultiAdapter((ob, request), name='test.html')
         self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
 
     def testNamedViewPageViewsCustomTraversr(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -611,7 +628,7 @@
             '''
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request)[1], (u'index.html', ))
 
@@ -625,8 +642,9 @@
 
 
     def testNamedViewNoPagesForCallable(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -639,13 +657,14 @@
             '''
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request), (view, ()))
 
     def testNamedViewNoPagesForNonCallable(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -658,13 +677,14 @@
             '''
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         view = removeSecurityProxy(view)
         self.assertEqual(getattr(view, 'browserDefault', None), None)
 
     def testNamedViewPageViewsNoDefault(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
         test3 = os.path.join(tests_path, 'testfiles', 'test3.pt')
 
         xmlconfig(StringIO(template %
@@ -683,7 +703,7 @@
             ''' % test3
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request)[1], (u'index.html', ))
 
@@ -699,8 +719,9 @@
         self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
 
     def testNamedViewPageViewsWithDefault(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
         test3 = os.path.join(tests_path, 'testfiles', 'test3.pt')
 
         xmlconfig(StringIO(template %
@@ -720,7 +741,7 @@
             ''' % test3
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request)[1], (u'test.html', ))
 
@@ -753,7 +774,7 @@
             '''
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         view = removeSecurityProxy(view)
         view.publishTraverse(request, 'index.html')
         
@@ -780,7 +801,7 @@
             '''
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         view = removeSecurityProxy(view)
         view.publishTraverse(request, 'index.html')
 
@@ -788,8 +809,9 @@
         ztapi.provideUtility(IPermission, Permission('p', 'P'), 'p')
 
         request = TestRequest()
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -809,17 +831,18 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='index.html')
+        v = component.getMultiAdapter((ob, request), name='index.html')
         v = ProxyFactory(v)
         zope.security.management.getInteraction().add(request)
         self.assertRaises(Exception, v)
-        v = zapi.getMultiAdapter((ob, request), name='action.html')
+        v = component.getMultiAdapter((ob, request), name='action.html')
         v = ProxyFactory(v)
         self.assertRaises(Exception, v)
 
     def testProtectedNamedViewPageViews(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -840,15 +863,16 @@
             '''
             ))
 
-        view = zapi.getMultiAdapter((ob, request), name='test')
+        view = component.getMultiAdapter((ob, request), name='test')
         self.assertEqual(view.browserDefault(request)[1], (u'index.html', ))
 
         v = view.publishTraverse(request, 'index.html')
         self.assertEqual(v(), 'V1 here')
 
     def testSkinnedPageView(self):
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -872,14 +896,15 @@
             '''
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='index.html')
+        v = component.getMultiAdapter((ob, request), name='index.html')
         self.assertEqual(v(), 'V1 here')
-        v = zapi.getMultiAdapter((ob, TestRequest(skin=ITestSkin)),
+        v = component.getMultiAdapter((ob, TestRequest(skin=ITestSkin)),
                                  name='index.html')
         self.assertEqual(v(), 'done')
 
     def testFactory(self):
-        self.assertEqual(zapi.queryAdapter(request, name='index.html'), None)
+        self.assertEqual(
+            component.queryAdapter(request, name='index.html'), None)
 
         xmlconfig(StringIO(template %
             '''
@@ -891,7 +916,7 @@
             '''
             ))
 
-        r = zapi.getAdapter(request, name='index.html')
+        r = component.getAdapter(request, name='index.html')
         self.assertEquals(r.__class__, MyResource)
         r = ProxyFactory(r)
         self.assertEqual(r.__name__, "index.html")
@@ -899,7 +924,7 @@
     def testFile(self):
         path = os.path.join(tests_path, 'testfiles', 'test.pt')
 
-        self.assertEqual(zapi.queryAdapter(request, name='test'), None)
+        self.assertEqual(component.queryAdapter(request, name='test'), None)
 
         xmlconfig(StringIO(template %
             '''
@@ -910,7 +935,7 @@
             ''' % path
             ))
 
-        r = zapi.getAdapter(request, name='index.html')
+        r = component.getAdapter(request, name='index.html')
         self.assertEquals(r.__class__, FileResource)
         r = ProxyFactory(r)
         self.assertEqual(r.__name__, "index.html")
@@ -928,7 +953,7 @@
 
 
     def testSkinResource(self):
-        self.assertEqual(zapi.queryAdapter(request, name='test'), None)
+        self.assertEqual(component.queryAdapter(request, name='test'), None)
 
         path = os.path.join(tests_path, 'testfiles', 'test.pt')
         xmlconfig(StringIO(template % (
@@ -942,9 +967,9 @@
             ''' % path
             )))
 
-        self.assertEqual(zapi.queryAdapter(request, name='test'), None)
+        self.assertEqual(component.queryAdapter(request, name='test'), None)
 
-        r = zapi.getAdapter(TestRequest(skin=ITestSkin), name='test')
+        r = component.getAdapter(TestRequest(skin=ITestSkin), name='test')
         r = removeSecurityProxy(r)
         self.assertEqual(r._testData(), open(path, 'rb').read())
 
@@ -952,7 +977,8 @@
         path = os.path.join(tests_path, 'testfiles', 'test.pt')
 
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), name='index.html'), None)
+            component.queryMultiAdapter((ob, request), name='index.html'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -964,13 +990,13 @@
             ''' % path
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='index.html')
+        v = component.getMultiAdapter((ob, request), name='index.html')
         self.assertEqual(v().strip(), '<html><body><p>test</p></body></html>')
 
     def test_page_menu_within_different_layers(self):
         path = os.path.join(tests_path, 'testfiles', 'test.pt')
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), name='index.html'),
+            component.queryMultiAdapter((ob, request), name='index.html'),
             None)
 
         xmlconfig(StringIO(template %
@@ -997,14 +1023,15 @@
             ''' % (path, path)
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='index.html')
+        v = component.getMultiAdapter((ob, request), name='index.html')
         self.assertEqual(v().strip(), '<html><body><p>test</p></body></html>')
 
     def testtemplateWClass(self):
         path = os.path.join(tests_path, 'testfiles', 'test2.pt')
 
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), name='index.html'), None)
+            component.queryMultiAdapter((ob, request), name='index.html'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -1017,7 +1044,7 @@
             ''' % path
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='index.html')
+        v = component.getMultiAdapter((ob, request), name='index.html')
         self.assertEqual(v().strip(), '<html><body><p>42</p></body></html>')
 
     def testProtectedtemplate(self):
@@ -1025,8 +1052,9 @@
         path = os.path.join(tests_path, 'testfiles', 'test.pt')
 
         request = TestRequest()
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
-                         None)
+        self.assertEqual(
+            component.queryMultiAdapter((ob, request), name='test'),
+            None)
 
         xmlconfig(StringIO(template %
             '''
@@ -1052,12 +1080,12 @@
             ''' % path
             ))
 
-        v = zapi.getMultiAdapter((ob, request), name='xxx.html')
+        v = component.getMultiAdapter((ob, request), name='xxx.html')
         v = ProxyFactory(v)
         zope.security.management.getInteraction().add(request)
         self.assertRaises(Exception, v)
 
-        v = zapi.getMultiAdapter((ob, request), name='index.html')
+        v = component.getMultiAdapter((ob, request), name='index.html')
         v = ProxyFactory(v)
         self.assertEqual(v().strip(), '<html><body><p>test</p></body></html>')
 
@@ -1097,7 +1125,7 @@
     def testViewThatProvidesAnInterface(self):
         request = TestRequest()
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), IV, name='test'), None)
+            component.queryMultiAdapter((ob, request), IV, name='test'), None)
 
         xmlconfig(StringIO(template %
             '''
@@ -1110,7 +1138,7 @@
             '''
             ))
 
-        v = zapi.queryMultiAdapter((ob, request), IV, name='test')
+        v = component.queryMultiAdapter((ob, request), IV, name='test')
         self.assertEqual(v, None)
 
         xmlconfig(StringIO(template %
@@ -1125,12 +1153,12 @@
             '''
             ))
 
-        v = zapi.queryMultiAdapter((ob, request), IV, name='test')
+        v = component.queryMultiAdapter((ob, request), IV, name='test')
         self.assert_(isinstance(v, V1))
 
     def testUnnamedViewThatProvidesAnInterface(self):
         request = TestRequest()
-        self.assertEqual(zapi.queryMultiAdapter((ob, request), IV),
+        self.assertEqual(component.queryMultiAdapter((ob, request), IV),
                          None)
 
         xmlconfig(StringIO(template %
@@ -1143,7 +1171,7 @@
             '''
             ))
 
-        v = zapi.queryMultiAdapter((ob, request), IV)
+        v = component.queryMultiAdapter((ob, request), IV)
         self.assertEqual(v, None)
 
         xmlconfig(StringIO(template %
@@ -1157,7 +1185,7 @@
             '''
             ))
 
-        v = zapi.queryMultiAdapter((ob, request), IV)
+        v = component.queryMultiAdapter((ob, request), IV)
 
         self.assert_(isinstance(v, V1))
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py	2007-03-25 10:12:57 UTC (rev 73578)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py	2007-03-25 10:14:23 UTC (rev 73579)
@@ -20,12 +20,11 @@
 
 from zope.publisher.interfaces import NotFound
 from zope.proxy import isProxy
-from zope.security.proxy import removeSecurityProxy
 from zope.publisher.browser import TestRequest
+from zope.security import proxy
 from zope.security.checker import NamesChecker, ProxyFactory
 from zope.interface import implements
 
-from zope.app import zapi
 from zope.app.testing.placelesssetup import PlacelessSetup
 from zope.app.publisher.browser.directoryresource import \
      DirectoryResourceFactory, DirectoryResource
@@ -104,7 +103,7 @@
         file = files['test.gif']
         self.assertEquals(file(), 'http://127.0.0.1/@@/test_files/test.gif')
         subdir = files['subdir']
-        self.assert_(zapi.isinstance(subdir, DirectoryResource))
+        self.assert_(proxy.isinstance(subdir, DirectoryResource))
         file = subdir['test.gif']
         self.assertEquals(file(),
                           'http://127.0.0.1/@@/test_files/subdir/test.gif')
@@ -115,13 +114,13 @@
         resource = DirectoryResourceFactory(path, checker, 'files')(request)
 
         image = resource['test.gif']
-        self.assert_(zapi.isinstance(image, FileResource))
+        self.assert_(proxy.isinstance(image, FileResource))
         template = resource['test.pt']
-        self.assert_(zapi.isinstance(template, PageTemplateResource))
+        self.assert_(proxy.isinstance(template, PageTemplateResource))
         file = resource['test.txt']
-        self.assert_(zapi.isinstance(file, FileResource))
+        self.assert_(proxy.isinstance(file, FileResource))
         file = resource['png']
-        self.assert_(zapi.isinstance(file, FileResource))
+        self.assert_(proxy.isinstance(file, FileResource))
 
 def test_suite():
     return makeSuite(Test)

Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py	2007-03-25 10:12:57 UTC (rev 73578)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py	2007-03-25 10:14:23 UTC (rev 73579)
@@ -19,6 +19,7 @@
 from StringIO import StringIO
 from unittest import TestCase, main, makeSuite
 
+from zope import component
 from zope.configuration.exceptions import ConfigurationError
 from zope.configuration.xmlconfig import xmlconfig, XMLConfig
 from zope.interface import implements
@@ -29,7 +30,6 @@
 from zope.traversing.interfaces import IContainmentRoot
 
 import zope.app.publisher.browser
-from zope.app import zapi
 from zope.app.component.tests.views import IC
 from zope.app.component.interfaces import ISite
 from zope.app.publisher.browser.tests import support
@@ -69,7 +69,7 @@
         
     def test(self):
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), name='zmi_icon'),
+            component.queryMultiAdapter((ob, request), name='zmi_icon'),
             None)
 
         import zope.app.publisher.browser.tests as p
@@ -85,7 +85,7 @@
             ''' % path
             )))
 
-        view = zapi.getMultiAdapter((ob, request), name='zmi_icon')
+        view = component.getMultiAdapter((ob, request), name='zmi_icon')
         rname = 'zope-app-component-tests-views-IC-zmi_icon.gif'
         self.assertEqual(
             view(),
@@ -102,7 +102,8 @@
             ''' % path
             )))
 
-        view = zapi.getMultiAdapter((ob, request), name='zmi_icon_w_title')
+        view = component.getMultiAdapter(
+            (ob, request), name='zmi_icon_w_title')
         rname = 'zope-app-component-tests-views-IC-zmi_icon_w_title.gif'
         self.assertEqual(
             view(),
@@ -120,8 +121,8 @@
             ''' % path
             )))
 
-        view = zapi.getMultiAdapter((ob, request),
-                                    name='zmi_icon_w_width_and_height')
+        view = component.getMultiAdapter((ob, request),
+                                         name='zmi_icon_w_width_and_height')
         rname = ('zope-app-component-tests-views-IC-'
                  'zmi_icon_w_width_and_height.gif')
         self.assertEqual(
@@ -131,14 +132,14 @@
             % rname)
 
         # Make sure that the image was installed as a resource:
-        resource = ProxyFactory(zapi.getAdapter(request, name=rname))
+        resource = ProxyFactory(component.getAdapter(request, name=rname))
         self.assertRaises(Forbidden, getattr, resource, '_testData')
         resource = removeSecurityProxy(resource)
         self.assertEqual(resource._testData(), open(path, 'rb').read())
 
     def testResource(self):
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), name='zmi_icon'), None)
+            component.queryMultiAdapter((ob, request), name='zmi_icon'), None)
 
         import zope.app.publisher.browser.tests as p
         path = os.path.dirname(p.__file__)
@@ -154,7 +155,7 @@
             ''' % path
             )))
 
-        view = zapi.getMultiAdapter((ob, request), name='zmi_icon')
+        view = component.getMultiAdapter((ob, request), name='zmi_icon')
         rname = "zmi_icon_res"
         self.assertEqual(
             view(),
@@ -162,7 +163,7 @@
             'height="16" border="0" />'
             % rname)
 
-        resource = ProxyFactory(zapi.getAdapter(request, name=rname))
+        resource = ProxyFactory(component.getAdapter(request, name=rname))
 
         self.assertRaises(Forbidden, getattr, resource, '_testData')
         resource = removeSecurityProxy(resource)
@@ -170,7 +171,7 @@
 
     def testResourceErrors(self):
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), name='zmi_icon'), None)
+            component.queryMultiAdapter((ob, request), name='zmi_icon'), None)
 
         import zope.app.publisher.browser.tests as p
         path = os.path.dirname(p.__file__)

Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py	2007-03-25 10:12:57 UTC (rev 73578)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py	2007-03-25 10:14:23 UTC (rev 73579)
@@ -17,6 +17,7 @@
 """
 import unittest
 
+from zope import component
 from zope.configuration import xmlconfig
 from zope.configuration.exceptions import ConfigurationError
 from zope.app.component.tests.views import Request, IC, V1
@@ -24,7 +25,6 @@
 from zope.security.proxy import ProxyFactory
 from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
 
-from zope.app import zapi
 from zope.app.publisher import xmlrpc
 from zope.interface import implements
 
@@ -40,35 +40,35 @@
 
     def testView(self):
         self.assertEqual(
-            zapi.queryMultiAdapter((ob, request), name='test'), None)
+            component.queryMultiAdapter((ob, request), name='test'), None)
         xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
-        view = zapi.queryMultiAdapter((ob, request), name='test')
+        view = component.queryMultiAdapter((ob, request), name='test')
         self.assert_(V1 in view.__class__.__bases__)
         self.assert_(xmlrpc.MethodPublisher in view.__class__.__bases__)
 
     def testInterfaceProtectedView(self):
         xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
-        v = zapi.getMultiAdapter((ob, request), name='test2')
+        v = component.getMultiAdapter((ob, request), name='test2')
         v = ProxyFactory(v)
         self.assertEqual(v.index(), 'V1 here')
         self.assertRaises(Exception, getattr, v, 'action')
 
     def testAttributeProtectedView(self):
         xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
-        v = zapi.getMultiAdapter((ob, request), name='test3')
+        v = component.getMultiAdapter((ob, request), name='test3')
         v = ProxyFactory(v)
         self.assertEqual(v.action(), 'done')
         self.assertRaises(Exception, getattr, v, 'index')
 
     def testInterfaceAndAttributeProtectedView(self):
         xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
-        v = zapi.getMultiAdapter((ob, request), name='test4')
+        v = component.getMultiAdapter((ob, request), name='test4')
         self.assertEqual(v.index(), 'V1 here')
         self.assertEqual(v.action(), 'done')
 
     def testDuplicatedInterfaceAndAttributeProtectedView(self):
         xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
-        v = zapi.getMultiAdapter((ob, request), name='test5')
+        v = component.getMultiAdapter((ob, request), name='test5')
         self.assertEqual(v.index(), 'V1 here')
         self.assertEqual(v.action(), 'done')
 
@@ -82,9 +82,9 @@
 
     def test_no_name(self):
         xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
-        v = zapi.getMultiAdapter((ob, request), name='index')
+        v = component.getMultiAdapter((ob, request), name='index')
         self.assertEqual(v(), 'V1 here')
-        v = zapi.getMultiAdapter((ob, request), name='action')
+        v = component.getMultiAdapter((ob, request), name='action')
         self.assertEqual(v(), 'done')
 
 



More information about the Zope3-Checkins mailing list