[Zope3-checkins] CVS: Zope3/src/zope/app/publication/tests - test_browserpublication.py:1.20.6.1 test_http.py:1.3.30.1 test_simplecomponenttraverser.py:1.7.42.1 test_xmlrpcpublication.py:1.3.6.1 test_zopepublication.py:1.17.6.1

Jim Fulton cvs-admin at zope.org
Sun Nov 9 11:08:52 EST 2003


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

Modified Files:
      Tag: adaptergeddon-branch
	test_browserpublication.py test_http.py 
	test_simplecomponenttraverser.py test_xmlrpcpublication.py 
	test_zopepublication.py 
Log Message:
Created a global presentation service that replaces the 
global view, resource, and skin services.

Now look up presentation components by adapting from a request type,
rather than adapting to a presentation type.





=== Zope3/src/zope/app/publication/tests/test_browserpublication.py 1.20 => 1.20.6.1 ===
--- Zope3/src/zope/app/publication/tests/test_browserpublication.py:1.20	Tue Sep 23 15:12:31 2003
+++ Zope3/src/zope/app/publication/tests/test_browserpublication.py	Sun Nov  9 11:08:21 2003
@@ -17,18 +17,17 @@
 """
 import unittest
 
+from zope.app.tests import ztapi
 from StringIO import StringIO
 
 from zope.exceptions import ForbiddenAttribute
 from zope.interface import Interface, implements
 
 from zope.component import getService
-from zope.app.services.servicenames import Views
 
 from zope.publisher.publish import publish
 from zope.publisher.browser import BrowserView, TestRequest
-from zope.publisher.interfaces.browser \
-     import IBrowserPresentation, IBrowserPublisher
+from zope.publisher.interfaces.browser import IBrowserPublisher
 
 from zope.proxy import removeAllProxies, getProxiedObject
 from zope.security.proxy import Proxy
@@ -122,12 +121,9 @@
 
         pub = BrowserPublication(self.db)
 
-        getService(None,'Views').provideView(I1, 'view',
-                           IBrowserPresentation, [DummyView])
-        getService(None,'Views').setDefaultViewName(I1,
-                             IBrowserPresentation, 'view')
-        getService(None, 'Views').provideView(None,
-                    '_traverse', IBrowserPresentation, [TestTraverser])
+        ztapi.browserView(I1, 'view', [DummyView])
+        ztapi.setDefaultViewName(I1, 'view')
+        ztapi.browserView(None, '_traverse', [TestTraverser])
 
         ob = O1()
 
@@ -182,8 +178,7 @@
                 self.counter += 1
                 return self.context[name]
 
-        provideView = getService(None, Views).provideView
-        provideView(I1, '_traverse', IBrowserPresentation, [Adapter])
+        ztapi.browserView(I1, '_traverse', [Adapter])
         ob = mydict()
         ob['bruce'] = SimpleObject('bruce')
         ob['bruce2'] = SimpleObject('bruce2')
@@ -202,8 +197,7 @@
             def browserDefault(self, request):
                 return (self.context['bruce'], 'dummy')
 
-        provideView=getService(None, Views).provideView
-        provideView(I1, '_traverse', IBrowserPresentation, [Adapter])
+        ztapi.browserView(I1, '_traverse', [Adapter])
         ob = mydict()
         ob['bruce'] =  SimpleObject('bruce')
         ob['bruce2'] =  SimpleObject('bruce2')
@@ -222,8 +216,7 @@
 
         pub = self.klass(self.db)
         ob = C()
-        provideView=getService(None, Views).provideView
-        provideView(I1, 'edit', IBrowserPresentation, [BobView])
+        ztapi.browserView(I1, 'edit', [BobView])
 
         r = self._createRequest('/@@edit;skin=zmi',pub)
         ob2 = pub.traverseName(r , ob, '@@edit;skin=zmi')
@@ -241,8 +234,7 @@
             x = SimpleObject(1)
         ob = C()
         r = self._createRequest('/x',pub)
-        provideView=getService(None, Views).provideView
-        provideView(None, '_traverse', IBrowserPresentation, [TestTraverser])
+        ztapi.browserView(None, '_traverse', [TestTraverser])
         ob2 = pub.traverseName(r, ob, 'x')
         self.assertRaises(ForbiddenAttribute, getattr, ob2, 'v')
         self.assertEqual(removeAllProxies(ob2).v, 1)
@@ -255,10 +247,8 @@
         ob = C()
         class V:
             def __init__(self, context, request): pass
-            implements(IBrowserPresentation)
         r = self._createRequest('/@@spam',pub)
-        provideView=getService(None, Views).provideView
-        provideView(I, 'spam', IBrowserPresentation, [V])
+        ztapi.browserView(I, 'spam', [V])
         ob2 = pub.traverseName(r, ob, '@@spam')
         self.assertEqual(ob2.__class__, V)
 


=== Zope3/src/zope/app/publication/tests/test_http.py 1.3 => 1.3.30.1 ===
--- 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	Sun Nov  9 11:08:21 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.7.42.1 ===
--- 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	Sun Nov  9 11:08:21 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.3.6.1 ===
--- 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	Sun Nov  9 11:08:21 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.17 => 1.17.6.1 ===
--- Zope3/src/zope/app/publication/tests/test_zopepublication.py:1.17	Sun Sep 21 13:32:37 2003
+++ Zope3/src/zope/app/publication/tests/test_zopepublication.py	Sun Nov  9 11:08:21 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
 
@@ -22,7 +23,6 @@
 
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.component.adapter import provideAdapter
-from zope.component.view import provideView, setDefaultViewName
 
 from zope.i18n.interfaces import IUserPreferredCharsets
 
@@ -49,6 +49,8 @@
 
 from zope.app.services.servicenames import Authentication
 
+from zope.publisher.interfaces import IRequest
+
 class BasePublicationTests(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
@@ -181,10 +183,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:
@@ -203,10 +208,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:
@@ -288,18 +294,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