[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture/tests - TestComponents.py:1.1.2.1 Request.py:1.1.2.3.14.1 TestViews.py:1.1.2.3.14.1 testAPI.py:1.1.2.15.8.1 testDirectives.py:1.1.2.8.8.1 testResources.py:1.1.2.5.8.1 testSkins.py:1.1.2.10.8.1 testViewDefinitions.py:1.1.2.4.8.1
Jim Fulton
jim@zope.com
Wed, 29 May 2002 11:10:22 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv12181/lib/python/Zope/ComponentArchitecture/tests
Modified Files:
Tag: Zope3InWonderland-branch
Request.py TestViews.py testAPI.py testDirectives.py
testResources.py testSkins.py testViewDefinitions.py
Added Files:
Tag: Zope3InWonderland-branch
TestComponents.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.
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/tests/TestComponents.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: TestComponents.py,v 1.1.2.1 2002/05/29 15:09:51 jim Exp $
"""
__metaclass__ = type # All classes are new style when run with Python 2.2+
from Interface import Interface
from Interface.Attribute import Attribute
class IApp(Interface):
a = Attribute('test attribute')
def f(): "test func"
class IContent(Interface): pass
class Content: __implements__ = IContent
class Comp:
__used_for__ = IContent
__implements__ = IApp
a=1
def f(): pass
comp = Comp()
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/Request.py 1.1.2.3 => 1.1.2.3.14.1 ===
class Request:
- def __init__(self,iface, skin):
+ def __init__(self, iface, skin=''):
self._iface = iface
self._skin = skin
# Implementation methods for interface
- # Zope.ComponentArchitecture.IViewService.IViewRequest
+ # Zope.ComponentArchitecture.IPresentationService.IPresentationRequest
- def getViewSkin(self):
- '''See interface IViewRequest'''
+ def getPresentationSkin(self):
+ '''See interface IPresentationRequest'''
return self._skin
- def getViewType(self):
- '''See interface IViewRequest'''
+ def getPresentationType(self):
+ '''See interface IPresentationRequest'''
return self._iface
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/TestViews.py 1.1.2.3 => 1.1.2.3.14.1 ===
__implements__ = IV
- def __init__(self,context):
+ def __init__(self,context, request):
self._context = context
class VZMI(V1):
pass
class R1:
- __implements__ = IV
-r1 = R1()
+ def __init__(self, request):
+ pass
+
+ __implements__ = IV
class RZMI(R1):
pass
-rZMI = RZMI()
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testAPI.py 1.1.2.15 => 1.1.2.15.8.1 ===
##############################################################################
import unittest, sys, Interface
+from Request import Request
class I1(Interface.Interface): pass
class I2(Interface.Interface): pass
class I3(Interface.Interface): pass
class Comp:
__implements__ = I2
- def __init__(self, context): self._context = context
- def getContext(self): return self._context
+ def __init__(self, context, request=None): self.context = context
class Comp2:
__implements__ = I3
- def __init__(self, context): self._context = context
- def getContext(self): return self._context
+ def __init__(self, context, request=None): self.context = context
comp = Comp(1)
@@ -31,13 +30,15 @@
__implements__ = I1
ob = Ob()
+
from PlacelessSetup import PlacelessSetup
class Test(PlacelessSetup, unittest.TestCase):
def testAdapter(self):
- from Zope.ComponentArchitecture import getAdapter, getService
+ from Zope.ComponentArchitecture \
+ import getAdapter, getService, queryAdapter
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
# if an object implements the interface you want to adapt to,
@@ -49,12 +50,12 @@
self.assertRaises(ComponentLookupError, getAdapter, ob, I2)
# ...otherwise, you get the default
- self.assertEquals(getAdapter(ob, I2, Test), Test)
+ self.assertEquals(queryAdapter(ob, I2, Test), Test)
getService(None, 'Adapters').provideAdapter(I1, I2, Comp)
c = getAdapter(ob, I2)
self.assertEquals(c.__class__, Comp)
- self.assertEquals(c.getContext(), ob)
+ self.assertEquals(c.context, ob)
def testMultipleAdapterFactories(self):
from Zope.ComponentArchitecture import getAdapter, getService
@@ -64,7 +65,7 @@
getService(None, 'Adapters').provideAdapter(I1, I2, [Comp2, Comp])
c = getAdapter(ob, I2)
self.assertEquals(c.__class__, Comp)
- self.assertEquals(c.getContext().getContext(), ob)
+ self.assertEquals(c.context.context, ob)
def testAdapterForInterfaceNone(self):
from Zope.ComponentArchitecture import getAdapter, getService
@@ -74,39 +75,42 @@
getService(None, 'Adapters').provideAdapter(None, I2, Comp)
c = getAdapter(ob, I2)
self.assertEquals(c.__class__, Comp)
- self.assertEquals(c.getContext(), ob)
+ self.assertEquals(c.context, ob)
def testUtility(self):
- from Zope.ComponentArchitecture import getUtility, getService
+ from Zope.ComponentArchitecture import getUtility, queryUtility
+ from Zope.ComponentArchitecture import getService
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
self.assertRaises(ComponentLookupError, getUtility, ob, I1)
self.assertRaises(ComponentLookupError, getUtility, ob, I2)
- self.assertEquals(getUtility(ob, I2, Test), Test)
+ self.assertEquals(queryUtility(ob, I2, Test), Test)
getService(None, 'Utilities').provideUtility(I2, comp)
self.assertEquals(id(getUtility(ob, I2)), id(comp))
def testView(self):
- from Zope.ComponentArchitecture import getView, getService
+ from Zope.ComponentArchitecture import getView, queryView, getService
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
- self.assertRaises(ComponentLookupError, getView, ob, 'foo', I1)
- self.assertRaises(ComponentLookupError, getView, ob, 'foo', I2)
- self.assertEquals(getView(ob, 'foo', I2, Test), Test)
+ self.assertRaises(ComponentLookupError,
+ getView, ob, 'foo', Request(I1))
+ self.assertRaises(ComponentLookupError,
+ getView, ob, 'foo', Request(I2))
+ self.assertEquals(queryView(ob, 'foo', Request(I2), Test), Test)
- getService(None, 'Views').provideView(I1, 'foo', I2, Comp)
- c = getView(ob, 'foo', I2)
+ getService(None, 'Views').provideView(I1, 'foo', I2, [Comp])
+ c = getView(ob, 'foo', Request(I2))
self.assertEquals(c.__class__, Comp)
- self.assertEquals(c.getContext(), ob)
+ self.assertEquals(c.context, ob)
self.assertRaises(ComponentLookupError,
- getView, ob, 'foo2', I1)
+ getView, ob, 'foo2', Request(I1))
self.assertRaises(ComponentLookupError,
- getView, ob, 'foo2', I2)
- self.assertEquals(getView(ob, 'foo2', I2, Test), Test)
+ getView, ob, 'foo2', Request(I2))
+ self.assertEquals(queryView(ob, 'foo2', Request(I2), Test), Test)
- self.assertEquals(getView( ob, 'foo2', I1, None), None)
+ self.assertEquals(queryView( ob, 'foo2', Request(I1), None), None)
def testDefaultViewName(self):
from Zope.ComponentArchitecture import getService
@@ -114,13 +118,13 @@
viewService = getService(None, 'Views')
self.assertRaises(NotFoundError,
viewService.getDefaultViewName,
- ob, I1)
+ ob, Request(I1))
viewService.setDefaultViewName(I1, I2, 'sample_name')
- self.assertEquals(viewService.getDefaultViewName(ob, I2),
+ self.assertEquals(viewService.getDefaultViewName(ob, Request(I2)),
'sample_name')
self.assertRaises(NotFoundError,
viewService.getDefaultViewName,
- ob, I1)
+ ob, Request(I1))
def test_suite():
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testDirectives.py 1.1.2.8 => 1.1.2.8.8.1 ===
#
##############################################################################
-import unittest, sys
+
+import unittest
+import sys
+from cStringIO import StringIO
+
from Zope.Configuration.xmlconfig import xmlconfig
-from Zope.ComponentArchitecture.tests.TestViews import \
- IV, IC, V1, VZMI, R1, RZMI
+from Zope.Security.Proxy import getTestProxyItems, getObject as proxiedObject
+
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
-from Zope.ComponentArchitecture import getView, getResource, createObject
-from cStringIO import StringIO
-from PlacelessSetup import PlacelessSetup
+from Zope.ComponentArchitecture import queryView, queryResource, createObject
from Zope.ComponentArchitecture import getDefaultViewName
+from PlacelessSetup import PlacelessSetup
+from Zope.ComponentArchitecture.tests.TestViews import \
+ IV, IC, V1, VZMI, R1, RZMI
+
+from Request import Request
+
template = """<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:test='http://www.zope.org/NS/Zope3/test'>
@@ -35,10 +43,113 @@
# XXX: tests for other directives needed
+ def testAdapter(self):
+ from Zope.ComponentArchitecture import getAdapter, queryAdapter
+
+ # Full import is critical!
+ from Zope.ComponentArchitecture.tests.TestComponents \
+ import Content, IApp, Comp
+
+ self.assertEqual(queryAdapter(Content(), IV, None), None)
+
+ xmlconfig(StringIO(template % (
+ """
+ <directive name="adapter" attributes="factory, provides, for"
+ handler="Zope.ComponentArchitecture.metaConfigure.adapter"
+ namespace="http://namespaces.zope.org/zope" />
+ <adapter
+ factory="Zope.ComponentArchitecture.tests.TestComponents.Comp"
+ provides="Zope.ComponentArchitecture.tests.TestComponents.IApp"
+ for="Zope.ComponentArchitecture.tests.TestComponents.IContent"
+ />
+ """
+ )))
+
+ self.assertEqual(getAdapter(Content(), IApp).__class__, Comp)
+
+ def testProtectedAdapter(self):
+ from Zope.ComponentArchitecture import getAdapter, queryAdapter
+
+ # Full import is critical!
+ from Zope.ComponentArchitecture.tests.TestComponents \
+ import Content, IApp, Comp
+
+ self.assertEqual(queryAdapter(Content(), IV, None), None)
+
+ xmlconfig(StringIO(template % (
+ """
+ <directive name="adapter" attributes="factory, provides, for"
+ handler="Zope.ComponentArchitecture.metaConfigure.adapter"
+ namespace="http://namespaces.zope.org/zope" />
+ <adapter
+ factory="Zope.ComponentArchitecture.tests.TestComponents.Comp"
+ provides="Zope.ComponentArchitecture.tests.TestComponents.IApp"
+ for="Zope.ComponentArchitecture.tests.TestComponents.IContent"
+ permission_id="Zope.Public"
+ />
+ """
+ )))
+
+ adapter = getAdapter(Content(), IApp)
+ items = [item[0] for item in getTestProxyItems(adapter)]
+ self.assertEqual(items, ['a', 'f'])
+ self.assertEqual(proxiedObject(adapter).__class__, Comp)
+
+ def testUtility(self):
+ from Zope.ComponentArchitecture import getUtility, queryUtility
+
+ # Full import is critical!
+ from Zope.ComponentArchitecture.tests.TestComponents \
+ import IApp, comp
+
+ self.assertEqual(queryUtility(None, IV, None), None)
+
+ xmlconfig(StringIO(template % (
+ """
+ <directive name="utility" attributes="factory, provides, for"
+ handler="Zope.ComponentArchitecture.metaConfigure.utility"
+ namespace="http://namespaces.zope.org/zope" />
+ <utility
+ component="Zope.ComponentArchitecture.tests.TestComponents.comp"
+ provides="Zope.ComponentArchitecture.tests.TestComponents.IApp"
+ />
+ """
+ )))
+
+ self.assertEqual(getUtility(None, IApp), comp)
+
+ def testProtectedUtility(self):
+ from Zope.ComponentArchitecture import getUtility, queryUtility
+
+ # Full import is critical!
+ from Zope.ComponentArchitecture.tests.TestComponents \
+ import IApp, comp
+
+ self.assertEqual(queryUtility(None, IV, None), None)
+
+ xmlconfig(StringIO(template % (
+ """
+ <directive name="utility" attributes="factory, provides, for"
+ handler="Zope.ComponentArchitecture.metaConfigure.utility"
+ namespace="http://namespaces.zope.org/zope" />
+ <utility
+ component="Zope.ComponentArchitecture.tests.TestComponents.comp"
+ provides="Zope.ComponentArchitecture.tests.TestComponents.IApp"
+ permission_id="Zope.Public"
+ />
+ """
+ )))
+
+ utility = getUtility(None, IApp)
+ items = [item[0] for item in getTestProxyItems(utility)]
+ self.assertEqual(items, ['a', 'f'])
+ self.assertEqual(proxiedObject(utility), comp)
+
+
def testView(self):
ob = Ob()
- self.assertEqual(getView(ob, 'test', IV, None), None)
+ self.assertEqual(queryView(ob, 'test', Request(IV), None), None)
xmlconfig(StringIO(template % (
"""
@@ -53,13 +164,13 @@
"""
)))
- self.assertEqual(getView(ob, 'test', IV, None).__class__, V1)
+ self.assertEqual(queryView(ob, 'test', Request(IV), None).__class__, V1)
def testDefaultView(self):
ob = Ob()
- self.assertEqual(getView(ob, 'test', IV, None), None)
+ self.assertEqual(queryView(ob, 'test', Request(IV), None), None)
xmlconfig(StringIO(template % (
"""
@@ -74,13 +185,13 @@
"""
)))
- self.assertEqual(getView(ob, 'test', IV, None).__class__, V1)
- self.assertEqual(getDefaultViewName(ob, IV), 'test')
+ self.assertEqual(queryView(ob, 'test', Request(IV), None).__class__, V1)
+ self.assertEqual(getDefaultViewName(ob, Request(IV)), 'test')
def testSKinView(self):
ob = Ob()
- self.assertEqual(getView(ob, 'test', IV, None), None)
+ self.assertEqual(queryView(ob, 'test', Request(IV), None), None)
xmlconfig(StringIO(template % (
"""
@@ -105,14 +216,14 @@
"""
)))
- self.assertEqual(getView(ob, 'test', IV, None).__class__, V1)
- self.assertEqual(getView(ob, 'test', IV, None, skin='zmi').__class__,
+ self.assertEqual(queryView(ob, 'test', Request(IV), None).__class__, V1)
+ self.assertEqual(queryView(ob, 'test', Request(IV, 'zmi'), None).__class__,
VZMI)
def testResource(self):
ob = Ob()
- self.assertEqual(getResource(ob, 'test', IV, None), None)
+ self.assertEqual(queryResource(ob, 'test', Request(IV), None), None)
xmlconfig(StringIO(template % (
"""
@@ -121,17 +232,19 @@
handler="Zope.ComponentArchitecture.metaConfigure.resource"
namespace="http://namespaces.zope.org/zope" />
<resource name="test"
- component="Zope.ComponentArchitecture.tests.TestViews.r1"
+ factory="Zope.ComponentArchitecture.tests.TestViews.R1"
type="Zope.ComponentArchitecture.tests.TestViews.IV"/>
"""
)))
- self.assertEqual(getResource(ob, 'test', IV, None).__class__, R1)
+ self.assertEqual(queryResource(ob, 'test', Request(IV), None
+ ).__class__,
+ R1)
def testSkinResource(self):
ob = Ob()
- self.assertEqual(getResource(ob, 'test', IV, None), None)
+ self.assertEqual(queryResource(ob, 'test', Request(IV), None), None)
xmlconfig(StringIO(template % (
"""
@@ -145,18 +258,18 @@
<skin name="zmi" layers="zmi,"
type="Zope.ComponentArchitecture.tests.TestViews.IV" />
<resource name="test"
- component="Zope.ComponentArchitecture.tests.TestViews.rZMI"
+ factory="Zope.ComponentArchitecture.tests.TestViews.RZMI"
layer="zmi"
type="Zope.ComponentArchitecture.tests.TestViews.IV"/>
<resource name="test"
- component="Zope.ComponentArchitecture.tests.TestViews.r1"
+ factory="Zope.ComponentArchitecture.tests.TestViews.R1"
type="Zope.ComponentArchitecture.tests.TestViews.IV"/>
"""
)))
- self.assertEqual(getResource(ob, 'test', IV, None).__class__, R1)
+ self.assertEqual(queryResource(ob, 'test', Request(IV), None).__class__, R1)
self.assertEqual(
- getResource(ob, 'test', IV, None, skin='zmi').__class__,
+ queryResource(ob, 'test', Request(IV, 'zmi'), None).__class__,
RZMI)
def testFactory(self):
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testResources.py 1.1.2.5 => 1.1.2.5.8.1 ===
from Zope.ComponentArchitecture import getService
from PlacelessSetup import PlacelessSetup
-from Zope.ComponentArchitecture import getResource
-from Zope.ComponentArchitecture import getRequestResource
+from Zope.ComponentArchitecture import getResource, queryResource
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
from Interface import Interface
from Request import Request
@@ -30,45 +29,52 @@
def testSkin(self):
class I2(Interface): pass
- class C1: __implements__ = I2
+ class C1:
+ def __init__(self, request): pass
+ __implements__ = I2
class C2(C1): pass
- getService(None,'Resources').provideResource('test', I2, C1())
- self.assertEqual(getResource(None, 'test', I2).__class__, C1)
+ getService(None,'Resources').provideResource('test', I2, C1)
+ self.assertEqual(getResource(None, 'test', Request(I2)).__class__, C1)
getService(None,'Skins').defineSkin('foo', I2, ('foo', ''))
- self.assertEqual(getResource(None, 'test', I2, skin='foo').__class__,
- C1)
- getService(None,'Resources').provideResource('test', I2, C2(),
- layer='foo')
- self.assertEqual(getResource(None, 'test', I2, skin='foo').__class__,
- C2)
+ self.assertEqual(
+ getResource(None, 'test', Request(I2, 'foo')).__class__,
+ C1)
+ getService(None,'Resources').provideResource('test', I2, C2,
+ layer='foo')
+ self.assertEqual(
+ getResource(None, 'test', Request(I2, 'foo')).__class__,
+ C2)
def testGetRequestResourceMethod(self):
class I2(Interface): pass
- class C1: __implements__ = I2
+ class C1:
+ def __init__(self, request): pass
+
+ __implements__ = I2
class C2(C1): pass
- getService(None,'Resources').provideResource('test', I2, C1())
+ getService(None,'Resources').provideResource('test', I2, C1)
self.assertEqual(
- getRequestResource(None, 'test', Request(I2, '') ).__class__,
+ getResource(None, 'test', Request(I2, '') ).__class__,
C1)
getService(None,'Skins').defineSkin('foo', I2, ('foo', ''))
self.assertEqual(
- getRequestResource(None, 'test', Request(I2, 'foo')).__class__,
+ getResource(None, 'test', Request(I2, 'foo')).__class__,
C1)
- getService(None,'Resources').provideResource('test', I2, C2(),
- layer='foo')
+ getService(None,'Resources').provideResource('test', I2, C2,
+ layer='foo')
self.assertEqual(
- getRequestResource(None, 'test', Request(I2, 'foo')).__class__,
+ getResource(None, 'test', Request(I2, 'foo')).__class__,
C2)
self.assertRaises(
ComponentLookupError,
- getRequestResource, None, 'test2', Request(I2, 'foo'))
+ getResource, None, 'test2', Request(I2, 'foo'))
self.assertEqual(
- getRequestResource(None, 'test2', Request(I2, 'foo'), None),
+ queryResource(None, 'test2', Request(I2, 'foo'), None),
None)
def test_suite():
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testSkins.py 1.1.2.10 => 1.1.2.10.8.1 ===
from PlacelessSetup import PlacelessSetup
-from Zope.ComponentArchitecture import getView, getService
-from Zope.ComponentArchitecture import getRequestView
+from Zope.ComponentArchitecture import getView, getService, queryView
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
from Interface import Interface
from Request import Request
+
class Test(PlacelessSetup, unittest.TestCase):
def testSkin(self):
@@ -29,22 +29,28 @@
class C1:
__implements__ = I2
__used_for__ = I1
- def __init__(self, o): self._context=o
+ def __init__(self, o, request): self._context=o
class C2(C1): pass
class C3(C1): pass
class O: __implements__ = I1
- getService(None, 'Views').provideView(I1, 'test', I2, C1)
- self.assertEqual(getView(O(), 'test', I2).__class__, C1)
+ getService(None, 'Views').provideView(I1, 'test', I2, [C1])
+ self.assertEqual(getView(O(), 'test', Request(I2)).__class__, C1)
getService(None, 'Skins').defineSkin('foo', I2, ('foo', ''))
- self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C1)
- getService(None, 'Views').provideView(None, 'test', I2, C2)
- self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C1)
- getService(None, 'Views').provideView(None, 'test', I2, C2, layer='foo')
- self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C2)
- getService(None, 'Views').provideView(I1, 'test', I2, C3, layer='foo')
- self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C3)
+ self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+ C1)
+ getService(None, 'Views').provideView(None, 'test', I2, [C2])
+ self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+ C1)
+ getService(None, 'Views').provideView(
+ None, 'test', I2, [C2], layer='foo')
+ self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+ C2)
+ getService(None, 'Views').provideView(
+ I1, 'test', I2, [C3], layer='foo')
+ self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+ C3)
@@ -56,38 +62,40 @@
class C1:
__implements__ = I2
__used_for__ = I1
- def __init__(self, o): self._context=o
+ def __init__(self, o, request): self._context=o
class C2(C1): pass
class C3(C1): pass
class O: __implements__ = I1
- getService(None, 'Views').provideView(I1, 'test', I2, C1)
- self.assertEqual(getRequestView(O(), 'test',
+ getService(None, 'Views').provideView(I1, 'test', I2, [C1])
+ self.assertEqual(getView(O(), 'test',
Request(I2,'') ).__class__, C1)
getService(None, 'Skins').defineSkin('foo', I2, ('foo', ''))
- self.assertEqual(getRequestView(O(), 'test',
+ self.assertEqual(getView(O(), 'test',
Request(I2, 'foo')).__class__, C1)
- getService(None, 'Views').provideView(None, 'test', I2, C2)
+ getService(None, 'Views').provideView(None, 'test', I2, [C2])
- self.assertEqual(getRequestView(O(), 'test',
+ self.assertEqual(getView(O(), 'test',
Request(I2, 'foo')).__class__, C1)
- getService(None, 'Views').provideView(None, 'test', I2, C2, layer='foo')
+ getService(None, 'Views').provideView(
+ None, 'test', I2, [C2], layer='foo')
- self.assertEqual(getRequestView(O(), 'test',
+ self.assertEqual(getView(O(), 'test',
Request(I2, 'foo')).__class__, C2)
- getService(None, 'Views').provideView(I1, 'test', I2, C3, layer='foo')
+ getService(None, 'Views').provideView(
+ I1, 'test', I2, [C3], layer='foo')
- self.assertEqual(getRequestView(O(), 'test',
+ self.assertEqual(getView(O(), 'test',
Request(I2, 'foo')).__class__, C3)
self.assertRaises(ComponentLookupError,
- getRequestView, O(), 'test2', Request(I2, 'foo'))
+ getView, O(), 'test2', Request(I2, 'foo'))
- self.assertEqual(getRequestView(O(), 'test2',
- Request(I2, 'foo'), None), None)
+ self.assertEqual(queryView(O(), 'test2',
+ Request(I2, 'foo'), None), None)
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testViewDefinitions.py 1.1.2.4 => 1.1.2.4.8.1 ===
C.layer = layer
- viewService.provideView(forinterface, name, IV, C,
+ viewService.provideView(forinterface, name, IV, [C],
layer=layer)
for name in ('foo', 'bar', 'baz'):
@@ -53,7 +53,7 @@
C.__used_for__ = IC2
C.layer = layer
C.__implements__ = ViewType
- viewService.provideView(IC2, name, IV, C,
+ viewService.provideView(IC2, name, IV, [C],
layer=layer)
for name in ('foo', 'bar', 'baz'):
@@ -63,7 +63,7 @@
C.__used_for__ = IC
C.layer = layer
C.__implements__ = ViewType
- viewService.provideView(IC, name, IV, C,
+ viewService.provideView(IC, name, IV, [C],
layer=layer)