[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testSimpleComponentTraverser.py:1.1.2.1.4.1 testZopePublication.py:1.1.2.27.2.1
Jim Fulton
jim@zope.com
Wed, 29 May 2002 11:10:21 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv12181/lib/python/Zope/App/ZopePublication/tests
Modified Files:
Tag: Zope3InWonderland-branch
testSimpleComponentTraverser.py testZopePublication.py
Log Message:
- Added permission_id attribute to adapter and utility directives.
- Got rid of old getView, getResource, and getDefaultViewName.
Renamed getRequestView to getView (and so on).
Changed view interface to use context, rather than getContext.
Introduced notion of presentation types (e.g. IBrowserPresentation,
which is cleaner than IBrowserPublisher).
- Began converting to get/queryFoo, which is much nicer.
- Many formatting fixups.
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testSimpleComponentTraverser.py 1.1.2.1 => 1.1.2.1.4.1 ===
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.27.2.1 ===
__implements__ = IBrowserPublisher
- def __init__(self, context):
- self._context = context
-
- def getContext(self):
- return self._context
+ def __init__(self, context, request):
+ self.context = context
class BasePublicationTests(PlacelessSetup, unittest.TestCase):
@@ -155,11 +152,11 @@
pub = BrowserPublication(self.db)
getService(None,'Views').provideView(I1, 'view',
- IBrowserPublisher, DummyView)
+ IBrowserPublisher, [DummyView])
getService(None,'Views').setDefaultViewName(I1,
IBrowserPublisher, 'view')
getService(None, 'Views').provideView(None,
- '_traverse', IBrowserPublisher, TestTraverser)
+ '_traverse', IBrowserPublisher, [TestTraverser])
ob = O1()
@@ -223,7 +220,7 @@
class Adapter:
" "
__implements__ = IBrowserPublisher
- def __init__(self, context):
+ def __init__(self, context, request):
self.context = context
self.counter = 0
@@ -232,7 +229,7 @@
return self.context[name]
provideView=getService(None, "Views").provideView
- provideView(I1, '_traverse', IBrowserPublisher, Adapter)
+ provideView(I1, '_traverse', IBrowserPublisher, [Adapter])
ob = mydict()
ob['bruce'] = SimpleObject('bruce')
ob['bruce2'] = SimpleObject('bruce2')
@@ -248,14 +245,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', IBrowserPublisher, [Adapter])
ob = mydict()
ob['bruce'] = SimpleObject('bruce')
ob['bruce2'] = SimpleObject('bruce2')
@@ -275,16 +272,16 @@
pub = self.klass(self.db)
ob = C()
provideView=getService(None, "Views").provideView
- provideView(I1, 'edit', IBrowserPublisher, BobView)
+ provideView(I1, 'edit', IBrowserPublisher, [BobView])
r = self._createRequest('/edit;skin=zmi;view',pub)
ob2 = pub.traverseName(r , ob, 'edit;skin=zmi;view')
- self.assertEqual(r.getViewSkin(), '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')
+ self.assertEqual(r.getPresentationSkin(), 'zmi')
self.assertEqual(ob2.__class__ , BobView)
def testTraverseName(self):
@@ -294,7 +291,7 @@
ob = C()
r = self._createRequest('/x',pub)
provideView=getService(None, "Views").provideView
- provideView(None, '_traverse', IBrowserPublisher, TestTraverser)
+ provideView(None, '_traverse', IBrowserPublisher, [TestTraverser])
ob2 = pub.traverseName(r, ob, 'x')
self.assertEqual(removeAllProxies(ob2).v, 1)
self.assertEqual(getWrapperContext(ob2), ob)
@@ -306,11 +303,11 @@
__implements__ = I
ob = C()
class V:
- def __init__(self, context): pass
+ def __init__(self, context, request): pass
__implements__ = IBrowserPublisher
r = self._createRequest('/spam;view',pub)
provideView=getService(None, "Views").provideView
- provideView(I, 'spam', IBrowserPublisher, V)
+ provideView(I, 'spam', IBrowserPublisher, [V])
ob2 = pub.traverseName(r, ob, 'spam;view')
self.assertEqual(removeAllProxies(ob2).__class__, V)
self.assertEqual(getWrapperContext(ob2), ob)