[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testZopePublication.py:1.1.2.11
Jim Fulton
jim@zope.com
Tue, 12 Feb 2002 20:01:20 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv18111/tests
Modified Files:
Tag: Zope-3x-branch
testZopePublication.py
Log Message:
Fixed bug in handling name traversers. Wrapping and security checks
weren't being done.
Added support for etc namespace, which, for now just has "Services".
I think later we need some sort of service for these.
Factored out traversal logic so we could use it when checking
ZMI tab access.
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testZopePublication.py 1.1.2.10 => 1.1.2.11 ===
from Zope.Publisher.DefaultPublication import DefaultPublication
from Zope.Publisher.IPublication import IPublication
-from Zope.ContextWrapper import Wrapper, getobject
+from Zope.ContextWrapper import Wrapper, getobject, getcontext
import ZODB
from ZODB.MappingStorage import MappingStorage
from Zope.Publisher.Exceptions import Retry
@@ -93,6 +93,7 @@
setSecurityPolicy(self.policy)
principalRegistry._clear()
principalRoleManager._clear()
+ _clear()
def testInterfacesVerify(self):
for interface in instancesOfObjectImplements(self.klass):
@@ -273,6 +274,42 @@
self.assertEqual(r.getViewSkin(), 'zmi')
self.assertEqual(ob2.__class__ , BobView)
+ def testTraverseName(self):
+ pub = self.klass(self.db)
+ class C:
+ x=1
+ ob = C()
+ r = self._createRequest('/x',pub)
+ provideView(None, '_traverse', IBrowserPublisher, DefaultTraverser)
+ ob2 = pub.traverseName(r, ob, 'x')
+ self.assertEqual(getobject(ob2), 1)
+ self.assertEqual(getcontext(ob2), ob)
+
+ def testTraverseNameView(self):
+ pub = self.klass(self.db)
+ class I(Interface): pass
+ class C:
+ __implements__ = I
+ ob = C()
+ class V:
+ def __init__(self, context): pass
+ __implements__ = IBrowserPublisher
+ r = self._createRequest('/spam;view',pub)
+ provideView(I, 'spam', IBrowserPublisher, V)
+ ob2 = pub.traverseName(r, ob, 'spam;view')
+ self.assertEqual(getobject(ob2).__class__, V)
+ self.assertEqual(getcontext(ob2), ob)
+
+ def testTraverseNameEtc(self):
+ pub = self.klass(self.db)
+ class C:
+ def getServiceManager(self):
+ return 1
+ ob = C()
+ r = self._createRequest('/Services;etc',pub)
+ ob2 = pub.traverseName(r, ob, 'Services;etc')
+ self.assertEqual(getobject(ob2), 1)
+ self.assertEqual(getcontext(ob2), ob)
def test_suite():
t1 = unittest.makeSuite(ZopePublicationTests, 'test')