[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/publication/tests/test_ The presentation service is gone.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Sep 17 12:16:21 EDT 2004


Log message for revision 27591:
  
  The presentation service is gone.
  
  Use adapter service and ztapi instead.
  
  


Changed:
  U   Zope3/trunk/src/zope/app/publication/tests/test_http.py
  U   Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
  U   Zope3/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py
  U   Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py


-=-
Modified: Zope3/trunk/src/zope/app/publication/tests/test_http.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_http.py	2004-09-17 16:16:19 UTC (rev 27590)
+++ Zope3/trunk/src/zope/app/publication/tests/test_http.py	2004-09-17 16:16:21 UTC (rev 27591)
@@ -16,15 +16,20 @@
 $Id$
 """
 from unittest import TestCase, TestSuite, main, makeSuite
-from zope.app import zapi
-import zope.app.publication.http
-from zope.publisher.http import HTTPRequest
-from zope.app.tests.placelesssetup import PlacelessSetup
 from StringIO import StringIO
+
 from zope.interface import Interface, implements
+from zope.publisher.http import HTTPRequest
 from zope.publisher.interfaces.http import IHTTPRequest
 
-class I(Interface): pass
+import zope.app.publication.http
+from zope.app import zapi
+from zope.app.tests import ztapi
+from zope.app.tests.placelesssetup import PlacelessSetup
+
+class I(Interface):
+    pass
+
 class C(object):
     spammed = 0
     implements(I)
@@ -46,8 +51,7 @@
         request = HTTPRequest(StringIO(''), StringIO(), {})
         request.method = 'SPAM'
 
-        s = zapi.getGlobalService(zapi.servicenames.Presentation)
-        s.provideView(I, 'SPAM', IHTTPRequest, V)
+        ztapi.provideView(I, IHTTPRequest, Interface, 'SPAM', V)
 
         ob = C()
         pub.callObject(request, ob)

Modified: Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py	2004-09-17 16:16:19 UTC (rev 27590)
+++ Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py	2004-09-17 16:16:21 UTC (rev 27591)
@@ -17,12 +17,12 @@
 """
 import unittest
 from zope.component.tests.request import Request
+from zope.exceptions import NotFoundError
+from zope.interface import Interface
+
 from zope.app.publication.traversers import SimpleComponentTraverser
-from zope.component import getService
-from zope.app.servicenames import Presentation
-from zope.interface import Interface
-from zope.exceptions import NotFoundError
 from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.app.tests import ztapi
 
 class I(Interface):
     pass
@@ -66,11 +66,11 @@
         req = Request(I, '')
 
         T = SimpleComponentTraverser(c, req)
-        getService(Presentation).provideView(None , 'foo', I, View)
+        ztapi.provideView(None, I, Interface, 'foo', View)
 
-        self.failUnless(T.publishTraverse(req,'foo').__class__ is View )
+        self.failUnless(T.publishTraverse(req,'foo').__class__ is View)
 
-        self.assertRaises(NotFoundError , T.publishTraverse, req ,'morebar')
+        self.assertRaises(NotFoundError, T.publishTraverse, req , 'morebar')
 
 
 

Modified: Zope3/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py	2004-09-17 16:16:19 UTC (rev 27590)
+++ Zope3/trunk/src/zope/app/publication/tests/test_xmlrpcpublication.py	2004-09-17 16:16:21 UTC (rev 27591)
@@ -21,7 +21,6 @@
      BasePublicationTests
 from zope.app.publication.traversers import TestTraverser
 from zope.app.publication.xmlrpc import XMLRPCPublication
-from zope.app.servicenames import Presentation
 from zope.component import getService
 from zope.interface import Interface, implements
 from zope.proxy import removeAllProxies
@@ -53,9 +52,8 @@
             x = SimpleObject(1)
         ob = C()
         r = self._createRequest('/x', pub)
-        provideView = getService(Presentation).provideView
-        provideView(None, '', IXMLRPCRequest, TestTraverser,
-                    providing=IXMLRPCPublisher)
+        ztapi.provideView(None, IXMLRPCRequest, IXMLRPCPublisher,
+                          '', TestTraverser)
         ob2 = pub.traverseName(r, ob, 'x')
         self.assertEqual(removeAllProxies(ob2).v, 1)
 
@@ -77,10 +75,9 @@
 
         ob = C()
         r = self._createRequest('/foo', pub)
-        provideView = getService(Presentation).provideView
-        setDefaultViewName = getService(Presentation).setDefaultViewName
-        provideView(I, 'view', IXMLRPCPresentation, V)
-        setDefaultViewName(I, IXMLRPCPresentation, 'view')
+
+        ztapi.provideView(I, IXMLRPCPresentation, Interface, 'view', V)
+        ztapi.setDefaultViewName(I, 'view', type=IXMLRPCPresentation)
         self.assertRaises(NotFound, pub.traverseName, r, ob, 'foo')
 
 
@@ -109,8 +106,7 @@
                           SimpleComponentTraverser)
 
         r = self._createRequest('/@@spam', pub)
-        provideView = getService(Presentation).provideView
-        provideView(I, 'spam', IXMLRPCRequest, V)
+        ztapi.provideView(I, IXMLRPCRequest, Interface, 'spam', V)
         ob2 = pub.traverseName(r, ob, '@@spam')
         self.assertEqual(removeAllProxies(ob2).__class__, V)
         

Modified: Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py	2004-09-17 16:16:19 UTC (rev 27590)
+++ Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py	2004-09-17 16:16:21 UTC (rev 27591)
@@ -193,13 +193,11 @@
         class IConflictError(Interface):
             pass
         classImplements(ConflictError, IConflictError)
-        s = zapi.getGlobalService(zapi.servicenames.Presentation)
-        s.setDefaultViewName(IConflictError,
-                             self.presentation_type, 'name')
+        ztapi.setDefaultViewName(IConflictError, 'name',
+                                 type=self.presentation_type)
         view_text = 'You had a conflict error'
-        s = zapi.getGlobalService(zapi.servicenames.Presentation) 
-        s.provideView(IConflictError, 'name', self.presentation_type,
-                      lambda obj, request: lambda: view_text)
+        ztapi.provideView(IConflictError, self.presentation_type, Interface,
+                          'name', lambda obj, request: lambda: view_text)
         try:
             raise ConflictError
         except:
@@ -217,11 +215,10 @@
         class IClassicError(Interface):
             pass
         classImplements(ClassicError, IClassicError)
-        s = zapi.getGlobalService(zapi.servicenames.Presentation)
-        s.setDefaultViewName(IClassicError, self.presentation_type, 'name')
+        ztapi.setDefaultViewName(IClassicError, 'name', self.presentation_type)
         view_text = 'You made a classic error ;-)'
-        s.provideView(IClassicError, 'name', self.presentation_type,
-                      [lambda obj,request: lambda: view_text])
+        ztapi.provideView(IClassicError, self.presentation_type, Interface,
+                          'name', lambda obj,request: lambda: view_text)
         try:
             raise ClassicError
         except:
@@ -345,9 +342,8 @@
         from zope.app.container.interfaces import ISimpleReadContainer
         from zope.app.container.traversal import ContainerTraverser
 
-        s = zapi.getGlobalService(zapi.servicenames.Presentation) 
-        s.provideView(ISimpleReadContainer, '', IRequest,
-                      ContainerTraverser, providing=IPublishTraverse)
+        ztapi.provideView(ISimpleReadContainer, IRequest, IPublishTraverse,
+                          '', ContainerTraverser)
 
         from zope.app.folder.interfaces import IFolder
         from zope.security.checker import defineChecker, InterfaceChecker



More information about the Zope3-Checkins mailing list