[Checkins] SVN: zope.app.publication/trunk/src/zope/app/publication/ Substitute zope.app.zapi by direct calls to its wrapped apis. See bug 219302

Lorenzo Gil lgs at sicem.biz
Thu Apr 24 15:02:11 EDT 2008


Log message for revision 85703:
  Substitute zope.app.zapi by direct calls to its wrapped apis. See bug 219302

Changed:
  U   zope.app.publication/trunk/src/zope/app/publication/ftp.py
  U   zope.app.publication/trunk/src/zope/app/publication/http.py
  U   zope.app.publication/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py
  U   zope.app.publication/trunk/src/zope/app/publication/traversers.py
  U   zope.app.publication/trunk/src/zope/app/publication/zopepublication.py

-=-
Modified: zope.app.publication/trunk/src/zope/app/publication/ftp.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/ftp.py	2008-04-24 18:40:44 UTC (rev 85702)
+++ zope.app.publication/trunk/src/zope/app/publication/ftp.py	2008-04-24 19:02:11 UTC (rev 85703)
@@ -16,10 +16,11 @@
 $Id$
 """
 __docformat__ = 'restructuredtext'
+import zope.component
+
 from zope.publisher.interfaces import NotFound
 from zope.publisher.publish import mapply
 
-from zope.app import zapi
 from zope.app.publication.zopepublication import ZopePublication
 
 
@@ -29,7 +30,9 @@
 
     def callObject(self, request, ob):
         method = request['command']
-        view = zapi.queryMultiAdapter((ob, request), name=method, default=self)
+        view = zope.component.queryMultiAdapter((ob, request),
+                                                name=method,
+                                                default=self)
         if view is self:
             raise NotFound(ob, method, request)
 

Modified: zope.app.publication/trunk/src/zope/app/publication/http.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/http.py	2008-04-24 18:40:44 UTC (rev 85702)
+++ zope.app.publication/trunk/src/zope/app/publication/http.py	2008-04-24 19:02:11 UTC (rev 85703)
@@ -20,7 +20,8 @@
 
 from zope.publisher.publish import mapply
 
-from zope.app import zapi
+import zope.component
+
 from zope.interface import implements, Attribute
 from zope.interface.common.interfaces import IException
 from zope.app.http.interfaces import IHTTPException
@@ -66,7 +67,8 @@
         # Exception handling, dont try to call request.method
         orig = ob
         if not IHTTPException.providedBy(ob):
-            ob = zapi.queryMultiAdapter((ob, request), name=request.method)
+            ob = zope.component.queryMultiAdapter((ob, request),
+                                                  name=request.method)
             ob = getattr(ob, request.method, None)
             if ob is None:
                 raise MethodNotAllowed(orig, request)

Modified: zope.app.publication/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py	2008-04-24 18:40:44 UTC (rev 85702)
+++ zope.app.publication/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py	2008-04-24 19:02:11 UTC (rev 85703)
@@ -20,6 +20,7 @@
 from zope.app.publication.tests.test_zopepublication import \
      BasePublicationTests
 from zope.app.publication.traversers import TestTraverser
+from zope.app.publication.traversers import SimpleComponentTraverser
 from zope.app.publication.xmlrpc import XMLRPCPublication
 from zope.interface import Interface, implements
 from zope.proxy import removeAllProxies
@@ -98,9 +99,6 @@
 
 
         # Register the simple traverser so we can traverse without @@
-        from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
-        from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
-        from zope.app.publication.traversers import SimpleComponentTraverser
         ztapi.provideView(Interface, IXMLRPCRequest, IXMLRPCPublisher, '',
                           SimpleComponentTraverser)
 
@@ -108,11 +106,11 @@
         ztapi.provideView(I, IXMLRPCRequest, Interface, 'spam', V)
         ob2 = pub.traverseName(r, ob, '@@spam')
         self.assertEqual(removeAllProxies(ob2).__class__, V)
-        
+
         ob2 = pub.traverseName(r, ob, 'spam')
         self.assertEqual(removeAllProxies(ob2).__class__, V)
-        
 
+
     def testTraverseNameSiteManager(self):
         pub = self.klass(self.db)
         class C(object):
@@ -123,7 +121,6 @@
         ob2 = pub.traverseName(r, ob, '++etc++site')
         self.assertEqual(removeAllProxies(ob2).v, 1)
 
-
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(XMLRPCPublicationTests),

Modified: zope.app.publication/trunk/src/zope/app/publication/traversers.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/traversers.py	2008-04-24 18:40:44 UTC (rev 85702)
+++ zope.app.publication/trunk/src/zope/app/publication/traversers.py	2008-04-24 19:02:11 UTC (rev 85703)
@@ -17,11 +17,13 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.app import zapi
+import zope.component
+
 from zope.interface import providedBy, implements
 from zope.publisher.interfaces import Unauthorized, NotFound
 from zope.publisher.interfaces.browser import IBrowserPublisher
 from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
+from zope.app.publisher.browser import getDefaultViewName
 
 class SimpleComponentTraverser(object):
     """Browser traverser for simple components that can only traverse to views
@@ -34,12 +36,12 @@
 
     def browserDefault(self, request):
         ob = self.context
-        view_name = zapi.getDefaultViewName(ob, request)
+        view_name = getDefaultViewName(ob, request)
         return ob, (view_name,)
 
     def publishTraverse(self, request, name):
         ob = self.context
-        view = zapi.queryMultiAdapter((ob, request), name=name)
+        view = zope.component.queryMultiAdapter((ob, request), name=name)
         if view is None:
             raise NotFound(ob, name)
         return view
@@ -55,7 +57,7 @@
     def browserDefault(self, request):
         ob = self.context
 
-        view_name = zapi.getDefaultViewName(ob, request)
+        view_name = getDefaultViewName(ob, request)
         view = self.publishTraverse(request, view_name)
         if hasattr(view, 'browserDefault'):
             view, path = view.browserDefault(request)
@@ -81,7 +83,7 @@
         ob = self.context
 
         if list(providedBy(ob)):
-            view_name = zapi.getDefaultViewName(ob, request)
+            view_name = getDefaultViewName(ob, request)
             return ob, (("@@%s" % view_name),)
 
         return ob, ()
@@ -89,7 +91,7 @@
     def publishTraverse(self, request, name):
         ob = self.context
         if name.startswith('@@'):
-            return zapi.getMultiAdapter((ob, request), name=name[6:])
+            return zope.component.getMultiAdaptera((ob, request), name=name[6:])
 
         if name.startswith('_'):
             raise Unauthorized(name)

Modified: zope.app.publication/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/zopepublication.py	2008-04-24 18:40:44 UTC (rev 85702)
+++ zope.app.publication/trunk/src/zope/app/publication/zopepublication.py	2008-04-24 19:02:11 UTC (rev 85703)
@@ -39,13 +39,13 @@
 from zope.error.interfaces import IErrorReportingUtility
 
 import zope.app.security.interfaces
-from zope.app import zapi
 from zope.app.applicationcontrol.applicationcontrol \
      import applicationControllerRoot
 from zope.app.exception.interfaces import ISystemErrorView
 from zope.app.publication.interfaces import BeforeTraverseEvent
 from zope.app.publication.interfaces import EndRequestEvent
 from zope.app.publication.publicationtraverse import PublicationTraverse
+from zope.app.publisher.browser import queryDefaultViewName
 from zope.app.security.interfaces import IUnauthenticatedPrincipal
 from zope.app.security.interfaces import IFallbackUnauthenticatedPrincipal
 from zope.app.security.interfaces import IAuthentication
@@ -222,7 +222,7 @@
         self.beginErrorHandlingTransaction(request, object,
                                            'error reporting utility')
         try:
-            errUtility = zapi.getUtility(IErrorReportingUtility)
+            errUtility = zope.component.getUtility(IErrorReportingUtility)
 
             # It is important that an error in errUtility.raising
             # does not propagate outside of here. Otherwise, nothing
@@ -315,9 +315,9 @@
                 # Give the exception instance its location and look up the
                 # view.
                 exception = LocationProxy(exc_info[1], loc, '')
-                name = zapi.queryDefaultViewName(exception, request)
+                name = queryDefaultViewName(exception, request)
                 if name is not None:
-                    view = zapi.queryMultiAdapter(
+                    view = zope.component.queryMultiAdapter(
                         (exception, request), name=name)
             except:
                 # Problem getting a view for this exception. Log an error.



More information about the Checkins mailing list