[Zope3-checkins] CVS: Zope3/src/zope/app/publication/tests - test_http.py:1.4 test_simplecomponenttraverser.py:1.8 test_xmlrpcpublication.py:1.4 test_zopepublication.py:1.19

Jim Fulton cvs-admin at zope.org
Fri Nov 21 12:10:21 EST 2003


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

Modified Files:
	test_http.py test_simplecomponenttraverser.py 
	test_xmlrpcpublication.py test_zopepublication.py 
Log Message:
Use the presentation service and register by request, rather than
presentation type.


=== Zope3/src/zope/app/publication/tests/test_http.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/publication/tests/test_http.py:1.3	Fri Jun  6 16:25:30 2003
+++ Zope3/src/zope/app/publication/tests/test_http.py	Fri Nov 21 12:10:20 2003
@@ -16,13 +16,13 @@
 """
 
 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.component.view import provideView
 from zope.interface import Interface, implements
-from zope.publisher.interfaces.http import IHTTPPresentation
+from zope.publisher.interfaces.http import IHTTPRequest
 
 class I(Interface): pass
 class C:
@@ -45,7 +45,9 @@
         pub = zope.app.publication.http.HTTPPublication(None)
         request = HTTPRequest(StringIO(''), StringIO(), {})
         request.method = 'SPAM'
-        provideView(I, 'SPAM', IHTTPPresentation, V)
+
+        s = zapi.getService(None, zapi.servicenames.Presentation)
+        s.provideView(I, 'SPAM', IHTTPRequest, V)
 
         ob = C()
         pub.callObject(request, ob)


=== Zope3/src/zope/app/publication/tests/test_simplecomponenttraverser.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/publication/tests/test_simplecomponenttraverser.py:1.7	Thu May  1 15:35:26 2003
+++ Zope3/src/zope/app/publication/tests/test_simplecomponenttraverser.py	Fri Nov 21 12:10:20 2003
@@ -20,7 +20,7 @@
 from zope.component.tests.request import Request
 from zope.app.publication.traversers import SimpleComponentTraverser
 from zope.component import getService
-from zope.app.services.servicenames import Views
+from zope.app.services.servicenames import Presentation
 from zope.interface import Interface
 from zope.exceptions import NotFoundError
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -67,7 +67,7 @@
         req = Request(I, '')
 
         T = SimpleComponentTraverser(c, req)
-        getService(None,Views).provideView(None , 'foo', I, [View])
+        getService(None, Presentation).provideView(None , 'foo', I, [View])
 
         self.failUnless(T.publishTraverse(req,'foo').__class__ is View )
 


=== Zope3/src/zope/app/publication/tests/test_xmlrpcpublication.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/publication/tests/test_xmlrpcpublication.py:1.3	Sun Sep 21 13:31:57 2003
+++ Zope3/src/zope/app/publication/tests/test_xmlrpcpublication.py	Fri Nov 21 12:10:20 2003
@@ -21,12 +21,13 @@
      BasePublicationTests
 from zope.app.publication.traversers import TestTraverser
 from zope.app.publication.xmlrpc import XMLRPCPublication
-from zope.app.services.servicenames import Views
+from zope.app.services.servicenames import Presentation
 from zope.component import getService
 from zope.interface import Interface, implements
 from zope.proxy import removeAllProxies
 from zope.publisher.interfaces import NotFound
 from zope.publisher.interfaces.xmlrpc import IXMLRPCPresentation
+from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
 from zope.publisher.xmlrpc import TestRequest
 
 
@@ -50,8 +51,8 @@
             x = SimpleObject(1)
         ob = C()
         r = self._createRequest('/x', pub)
-        provideView=getService(None, Views).provideView
-        provideView(None, '_traverse', IXMLRPCPresentation, [TestTraverser])
+        provideView=getService(None, Presentation).provideView
+        provideView(None, '_traverse', IXMLRPCRequest, [TestTraverser])
         ob2 = pub.traverseName(r, ob, 'x')
         self.assertEqual(removeAllProxies(ob2).v, 1)
 
@@ -73,8 +74,8 @@
 
         ob = C()
         r = self._createRequest('/foo', pub)
-        provideView=getService(None, Views).provideView
-        setDefaultViewName=getService(None, Views).setDefaultViewName
+        provideView=getService(None, Presentation).provideView
+        setDefaultViewName=getService(None, Presentation).setDefaultViewName
         provideView(I, 'view', IXMLRPCPresentation, [V])
         setDefaultViewName(I, IXMLRPCPresentation, 'view')
         self.assertRaises(NotFound, pub.traverseName, r, ob, 'foo')
@@ -97,8 +98,8 @@
             implements(IXMLRPCPresentation)
 
         r = self._createRequest('/@@spam', pub)
-        provideView=getService(None, Views).provideView
-        provideView(I, 'spam', IXMLRPCPresentation, [V])
+        provideView=getService(None, Presentation).provideView
+        provideView(I, 'spam', IXMLRPCRequest, [V])
         ob2 = pub.traverseName(r, ob, '@@spam')
         self.assertEqual(removeAllProxies(ob2).__class__, V)
         
@@ -127,10 +128,10 @@
                 return 'foo'
 
         r = self._createRequest('/spam', pub)
-        provideView=getService(None, Views).provideView
-        setDefaultViewName=getService(None, Views).setDefaultViewName
-        provideView(I, 'view', IXMLRPCPresentation, [V])
-        setDefaultViewName(I, IXMLRPCPresentation, 'view')
+        provideView=getService(None, Presentation).provideView
+        setDefaultViewName=getService(None, Presentation).setDefaultViewName
+        provideView(I, 'view', IXMLRPCRequest, [V])
+        setDefaultViewName(I, IXMLRPCRequest, 'view')
 
         ob2 = pub.traverseName(r, ob, '@@spam')
         self.assertEqual(removeAllProxies(ob2).__name__, V.spam.__name__)


=== Zope3/src/zope/app/publication/tests/test_zopepublication.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/publication/tests/test_zopepublication.py:1.18	Mon Nov  3 16:37:58 2003
+++ Zope3/src/zope/app/publication/tests/test_zopepublication.py	Fri Nov 21 12:10:20 2003
@@ -14,6 +14,7 @@
 import unittest
 import sys
 
+from zope.app import zapi
 from zope.interface.verify import verifyClass
 from zope.interface import implements, classImplements, implementedBy
 
@@ -21,8 +22,7 @@
 from zodb.storage.mapping import MappingStorage
 
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component.adapter import provideAdapter
-from zope.component.view import provideView, setDefaultViewName
+from zope.app.tests import ztapi
 
 from zope.i18n.interfaces import IUserPreferredCharsets
 
@@ -49,11 +49,13 @@
 
 from zope.app.services.servicenames import Authentication
 
+from zope.publisher.interfaces import IRequest
+
 class BasePublicationTests(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
         PlacelessSetup.setUp(self)
-        provideAdapter(IHTTPRequest, IUserPreferredCharsets, HTTPCharsets)
+        ztapi.provideAdapter(IHTTPRequest, IUserPreferredCharsets, HTTPCharsets)
         self.policy = setSecurityPolicy(
             simplepolicies.PermissiveSecurityPolicy()
             )
@@ -179,10 +181,13 @@
         class IConflictError(Interface):
             pass
         classImplements(ConflictError, IConflictError)
-        setDefaultViewName(IConflictError, self.presentation_type, 'name')
+        s = zapi.getService(None, zapi.servicenames.Presentation)
+        s.setDefaultViewName(IConflictError,
+                             self.presentation_type, 'name')
         view_text = 'You had a conflict error'
-        provideView(IConflictError, 'name', self.presentation_type,
-                    [lambda obj,request: lambda: view_text])
+        s = zapi.getService(None, zapi.servicenames.Presentation) 
+        s.provideView(IConflictError, 'name', self.presentation_type,
+                      [lambda obj,request: lambda: view_text])
         try:
             raise ConflictError
         except:
@@ -200,10 +205,11 @@
         class IClassicError(Interface):
             pass
         classImplements(ClassicError, IClassicError)
-        setDefaultViewName(IClassicError, self.presentation_type, 'name')
+        s = zapi.getService(None, zapi.servicenames.Presentation)
+        s.setDefaultViewName(IClassicError, self.presentation_type, 'name')
         view_text = 'You made a classic error ;-)'
-        provideView(IClassicError, 'name', self.presentation_type,
-                    [lambda obj,request: lambda: view_text])
+        s.provideView(IClassicError, 'name', self.presentation_type,
+                      [lambda obj,request: lambda: view_text])
         try:
             raise ClassicError
         except:
@@ -237,7 +243,7 @@
         class IConflictError(Interface):
             pass
         classImplements(ConflictError, IConflictError)
-        provideAdapter(IConflictError, IExceptionSideEffects, factory)
+        ztapi.provideAdapter(IConflictError, IExceptionSideEffects, factory)
         exception = ConflictError()
         try:
             raise exception
@@ -285,18 +291,16 @@
 
         request = TestRequest('/f1/f2')
 
-        from zope.component.view import provideView
         from zope.app.interfaces.container import ISimpleReadContainer
         from zope.app.container.traversal import ContainerTraverser
-        from zope.component.interfaces import IPresentation
-        provideView(ISimpleReadContainer, '_traverse', IPresentation,
-                    ContainerTraverser)
+
+        s = zapi.getService(None, zapi.servicenames.Presentation) 
+        s.provideView(ISimpleReadContainer, '_traverse', IRequest,
+                      ContainerTraverser)
 
         from zope.app.interfaces.content.folder import IFolder
         from zope.security.checker import defineChecker, InterfaceChecker
         defineChecker(Folder, InterfaceChecker(IFolder))
-        
-        request.setViewType(IPresentation)
 
         publication = ZopePublication(self.db)
 




More information about the Zope3-Checkins mailing list