[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testSimpleComponentTraverser.py:1.1.2.2 testZopePublication.py:1.1.2.28

Jim Fulton jim@zope.com
Fri, 7 Jun 2002 10:41:53 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv12187/lib/python/Zope/App/ZopePublication/tests

Modified Files:
      Tag: Zope-3x-branch
	testSimpleComponentTraverser.py testZopePublication.py 
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals): 
- RenameAllowToRequire

- GroupClassRelatedDirectivesInClassDirective

- ViewInterfaceAndSimplification

- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes

- TwoArgumentViewConstructors

- ImplementsInZCML

- SimpleViewCreationInZCML

- RemoveGetView

- ReplaceProtectWithAllow

- ViewMethodsAsViews

- MergeProtectionAndComponentDefinitions

There were also various security fixes resulting of better integration
of security with components.


=== Zope3/lib/python/Zope/App/ZopePublication/tests/testSimpleComponentTraverser.py 1.1.2.1 => 1.1.2.2 ===
 class View:
 
-    def __init__(self, comp):
+    def __init__(self, comp, request):
         self._comp = comp
 
 
@@ -62,7 +62,7 @@
         c   = Container( foo=foo )
         req = Request( I, '')
         
-        T = SimpleComponentTraverser(c)
+        T = SimpleComponentTraverser(c, req)
         
         self.assertRaises(NotFoundError , T.publishTraverse, req ,'foo')
 
@@ -75,8 +75,8 @@
         c   = Container( foo=foo )
         req = Request( I, '')
         
-        T = SimpleComponentTraverser(c)
-        getService(None,"Views").provideView(None , 'foo', I, View)
+        T = SimpleComponentTraverser(c, req)
+        getService(None,"Views").provideView(None , 'foo', I, [View])
         
         self.failUnless(T.publishTraverse(req,'foo').__class__ is View )
         


=== Zope3/lib/python/Zope/App/ZopePublication/tests/testZopePublication.py 1.1.2.27 => 1.1.2.28 ===
 from Zope.Publisher.Publish import publish
 from Zope.Publisher.Browser.BrowserRequest import TestRequest
+from Zope.Publisher.Browser.BrowserView import BrowserView
 from Zope.App.ZopePublication.ZopePublication import ZopePublication
 from Zope.App.ZopePublication.Browser.Publication import BrowserPublication
 from Zope.Configuration.name import resolve
 from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
+from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
 from Zope.Publisher.DefaultPublication import TestPublication
 from Zope.Publisher.IPublication import IPublication
 from Zope.Proxy.ContextWrapper import getWrapperContext
@@ -63,15 +65,9 @@
     def browserDefault(self, request):
         return self, ['bruce']
 
-class DummyView(DummyPublished):
+class DummyView(DummyPublished, BrowserView):
 
-    __implements__ = IBrowserPublisher
-    
-    def __init__(self, context):
-        self._context = context
-        
-    def getContext(self):
-        return self._context
+    __implements__ = DummyPublished.__implements__, BrowserView.__implements__
 
 
 class BasePublicationTests(PlacelessSetup, unittest.TestCase):
@@ -120,25 +116,25 @@
     test browser default
 
     many views lead to a default view
-    <base href="/somepath/view;view/view_method">
+    <base href="/somepath/view::view/view_method">
 
     """
     klass = BrowserPublication
     
     def testBaseTagNoBase(self):
-        self._testBaseTags('/somepath/view;view/', '')
+        self._testBaseTags('/somepath/view::view/', '')
 
     def testBaseTag1(self):
-        self._testBaseTags('/somepath/view;view',
-                           'http://127.0.0.1/somepath/view;view/bruce')
+        self._testBaseTags('/somepath/view::view',
+                           'http://127.0.0.1/somepath/view::view/bruce')
 
     def testBaseTag2(self):
         self._testBaseTags('/somepath/',
-                           'http://127.0.0.1/somepath/view;view/bruce')
+                           'http://127.0.0.1/somepath/view::view/bruce')
 
     def testBaseTag3(self):
         self._testBaseTags('/somepath',
-                           'http://127.0.0.1/somepath/view;view/bruce')
+                           'http://127.0.0.1/somepath/view::view/bruce')
         
 
 
@@ -155,11 +151,11 @@
         pub = BrowserPublication(self.db)
         
         getService(None,'Views').provideView(I1, 'view',
-                           IBrowserPublisher, DummyView)
+                           IBrowserPresentation, [DummyView])
         getService(None,'Views').setDefaultViewName(I1,
-                             IBrowserPublisher, 'view')
+                             IBrowserPresentation, 'view')
         getService(None, 'Views').provideView(None,
-                    '_traverse', IBrowserPublisher, TestTraverser)
+                    '_traverse', IBrowserPresentation, [TestTraverser])
         
         ob = O1()
 
@@ -223,7 +219,7 @@
         class Adapter:
             " "
             __implements__ = IBrowserPublisher
-            def __init__(self, context):
+            def __init__(self, context, request):
                 self.context = context
                 self.counter = 0
 
@@ -232,7 +228,7 @@
                 return self.context[name]
 
         provideView=getService(None, "Views").provideView
-        provideView(I1, '_traverse', IBrowserPublisher, Adapter)
+        provideView(I1, '_traverse', IBrowserPresentation, [Adapter])
         ob = mydict()
         ob['bruce'] =  SimpleObject('bruce')
         ob['bruce2'] =  SimpleObject('bruce2')
@@ -248,14 +244,14 @@
 
         class Adapter:
             __implements__ = IBrowserPublisher
-            def __init__(self, context):
+            def __init__(self, context, request):
                 self.context = context
 
             def browserDefault(self, request):
                 return (self.context['bruce'], 'dummy')
 
         provideView=getService(None, "Views").provideView
-        provideView(I1, '_traverse', IBrowserPublisher, Adapter)
+        provideView(I1, '_traverse', IBrowserPresentation, [Adapter])
         ob = mydict()
         ob['bruce'] =  SimpleObject('bruce')
         ob['bruce2'] =  SimpleObject('bruce2')
@@ -275,16 +271,16 @@
         pub = self.klass(self.db)
         ob = C()
         provideView=getService(None, "Views").provideView
-        provideView(I1, 'edit', IBrowserPublisher, BobView)
+        provideView(I1, 'edit', IBrowserPresentation, [BobView])
 
-        r = self._createRequest('/edit;skin=zmi;view',pub)
-        ob2 = pub.traverseName(r , ob, 'edit;skin=zmi;view')
-        self.assertEqual(r.getViewSkin(), 'zmi')
+        r = self._createRequest('/view::edit;skin=zmi',pub)
+        ob2 = pub.traverseName(r , ob, 'view::edit;skin=zmi')
+        self.assertEqual(r.getPresentationSkin(), 'zmi')
         self.assertEqual(ob2.__class__ , BobView)
 
-        r = self._createRequest('/edit;view;skin=zmi',pub)
-        ob2 = pub.traverseName(r , ob, 'edit;view;skin=zmi')
-        self.assertEqual(r.getViewSkin(), 'zmi')
+        r = self._createRequest('/view::edit;skin=zmi',pub)
+        ob2 = pub.traverseName(r , ob, 'view::edit;skin=zmi')
+        self.assertEqual(r.getPresentationSkin(), 'zmi')
         self.assertEqual(ob2.__class__ , BobView)
 
     def testTraverseName(self):
@@ -294,7 +290,7 @@
         ob = C()
         r = self._createRequest('/x',pub)
         provideView=getService(None, "Views").provideView
-        provideView(None, '_traverse', IBrowserPublisher, TestTraverser)
+        provideView(None, '_traverse', IBrowserPresentation, [TestTraverser])
         ob2 = pub.traverseName(r, ob, 'x')
         self.assertEqual(removeAllProxies(ob2).v, 1)
         self.assertEqual(getWrapperContext(ob2), ob)
@@ -306,12 +302,12 @@
             __implements__ = I
         ob = C()
         class V:
-            def __init__(self, context): pass
-            __implements__ = IBrowserPublisher
-        r = self._createRequest('/spam;view',pub)
+            def __init__(self, context, request): pass
+            __implements__ = IBrowserPresentation
+        r = self._createRequest('/view::spam',pub)
         provideView=getService(None, "Views").provideView
-        provideView(I, 'spam', IBrowserPublisher, V)
-        ob2 = pub.traverseName(r, ob, 'spam;view')
+        provideView(I, 'spam', IBrowserPresentation, [V])
+        ob2 = pub.traverseName(r, ob, 'view::spam')
         self.assertEqual(removeAllProxies(ob2).__class__, V)
         self.assertEqual(getWrapperContext(ob2), ob)
 
@@ -321,8 +317,8 @@
             def getServiceManager(self):
                 return SimpleObject(1)
         ob = C()
-        r = self._createRequest('/Services;etc',pub)
-        ob2 = pub.traverseName(r, ob, 'Services;etc')
+        r = self._createRequest('/etc::Services',pub)
+        ob2 = pub.traverseName(r, ob, 'etc::Services')
         self.assertEqual(removeAllProxies(ob2).v, 1)
         self.assertEqual(getWrapperContext(ob2), ob)
 
@@ -330,10 +326,10 @@
         from Zope.App.OFS.ApplicationControl.ApplicationControl \
              import ApplicationController
         pub = self.klass(self.db)
-        r = self._createRequest('/ApplicationController;etc;skin=zmi',pub)
-        ac = pub.traverseName(r, None, 'ApplicationController;etc;skin=zmi')
+        r = self._createRequest('/etc::ApplicationController;skin=zmi',pub)
+        ac = pub.traverseName(r, None, 'etc::ApplicationController;skin=zmi')
         self.assertEqual(ac, ApplicationController)
-        r = self._createRequest('/ApplicationController;etc;skin=zmi',pub)
+        r = self._createRequest('/etc::ApplicationController;skin=zmi',pub)
         app = r.getPublication().getApplication(r)
         self.assertEqual(app, ApplicationController)
         self.failIf(r.getTraversalStack())