[Zope3-checkins] CVS: Zope3/src/zope/app/publication/tests - test_browserpublication.py:1.4

Jim Fulton jim@zope.com
Tue, 31 Dec 2002 13:27:29 -0500


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

Modified Files:
	test_browserpublication.py 
Log Message:
Hold on to your butts! :)

In an effort to make zcml view definitions even easier to understand
(see 
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/ZCMLBrowserViewDirectiveSimplification
)

I've finished a long-overdue refactoring of the configuration
directives for defining views. The logic is now a good bit less
complicated. 

I also simplified the way security assertions on views were
handled. To make this work right, I had to fix a bug in the
publication machinery. Now, as objects are traversed, the results of
traversal are put in security proxies.  This is really necessary to
treat URLs as "untrusted code", which they are.

I updated the meta-configuration directives for views and ran the zcml
documentation utility, so there is now documentation for the (new)
view directives. See the files 'page', 'pages', and 'view', in 
'doc/zcml/namespaces.zope.org/browser'.

I feel these changes are highly desireable for the alpha, but they are
significant enough that the chance of breakage is a lot higher than
I'd like just before the alpha.  I'd appreciate it if folks would let
me know if I've broken anything.



=== Zope3/src/zope/app/publication/tests/test_browserpublication.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/publication/tests/test_browserpublication.py:1.3	Thu Dec 26 13:53:13 2002
+++ Zope3/src/zope/app/publication/tests/test_browserpublication.py	Tue Dec 31 13:26:58 2002
@@ -25,6 +25,8 @@
 
 from zope.proxy.context import getWrapperContext, wrapperTypes
 from zope.proxy.introspection import removeAllProxies
+from zope.security.proxy import Proxy, getObject
+
 
 from zope.security.checker import defineChecker, NamesChecker
 
@@ -36,6 +38,7 @@
 from zope.app.publication.traversers import TestTraverser
 from zope.app.publication.tests.test_zopepublication \
      import BasePublicationTests as BasePublicationTests_
+from zope.security.checker import NamesChecker
 
 
 def foo():
@@ -54,8 +57,12 @@
     def browserDefault(self, request):
         return self, ['bruce']
 
+
+
 class DummyView(DummyPublished, BrowserView):
 
+    __Security_checker__ = NamesChecker(["browserDefault", "publishTraverse"])
+
     __implements__ = DummyPublished.__implements__, BrowserView.__implements__
 
 
@@ -169,6 +176,8 @@
         ob = DummyPublished()
         ob2 = pub.traverseName(self._createRequest('/bruce',pub), ob, 'bruce')
         self.failUnless(ob2 is not ob)
+        self.failUnless(type(ob2) is Proxy)
+        ob2 = getObject(ob2)
         self.failUnless(type(ob2) in wrapperTypes)
 
     def testAdaptedTraverseNameWrapping(self):
@@ -191,6 +200,8 @@
         ob['bruce2'] =  SimpleObject('bruce2')
         pub = self.klass(self.db)
         ob2 = pub.traverseName(self._createRequest('/bruce',pub), ob, 'bruce')
+        self.failUnless(type(ob2) is Proxy)
+        ob2 = getObject(ob2)
         self.failUnless(type(ob2) in wrapperTypes)
         unw = removeAllProxies(ob2)
         self.assertEqual(unw.v, 'bruce')
@@ -213,6 +224,8 @@
         pub = self.klass(self.db)
         ob2, x = pub.getDefaultTraversal(self._createRequest('/bruce',pub), ob)
         self.assertEqual(x, 'dummy')
+        self.failUnless(type(ob2) is Proxy)
+        ob2 = getObject(ob2)
         self.failUnless(type(ob2) in wrapperTypes)
         unw = removeAllProxies(ob2)
         self.assertEqual(unw.v, 'bruce')