[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture/tests - PlacelessSetup.py:1.1.2.1 TestFactory.py:1.1.2.3 testAPI.py:1.1.2.15 testDirectives.py:1.1.2.8 testProvideFactory.py:1.1.2.3 testResources.py:1.1.2.5 testService.py:1.1.2.8 testServiceManagerContainer.py:1.1.2.8 testSkins.py:1.1.2.10 testViewDefinitions.py:1.1.2.4

Gary Poster garyposter@earthlink.net
Mon, 29 Apr 2002 19:20:42 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv1556/ComponentArchitecture/tests

Modified Files:
      Tag: Zope-3x-branch
	TestFactory.py testAPI.py testDirectives.py 
	testProvideFactory.py testResources.py testService.py 
	testServiceManagerContainer.py testSkins.py 
	testViewDefinitions.py 
Added Files:
      Tag: Zope-3x-branch
	PlacelessSetup.py 
Log Message:
ComponentArchitecture reorganization; addition of for_container; addition of IWriteContainer.isAddable.

good news: all tests pass; bad news: after the new security system, my changes have some problems.  I had to punt on the default contents view of all folders for instance--hasServiceManager is causing a problem for some reason I couldn't divine, even with Shane's Checker tool.  I commented out the offending code on the contents.pt just to keep things up.

I tagged before committing: gary_CA-reorganization

changes more in depth (as I understand it, all or most approved :-) ):

(in ComponentArchitecture:)
 * changing implementation names to Global* (i.e., AdapterService becomes 
GlobalAdapterService) and giving each its own file (many are clumped together 
in hooks.py)
 * removing hooks.py in ComponentArchitecture, putting all functions in appropriate module above (i.e. getAdapter will be in the adapter module)
 * largely removing indirection (_hook) except for getService and 
getNextService
 * changing IServiceService.py to IServiceManager
 * changing Service.py to GlobalServiceManager.py (and class name too)
 * removing "provide*" functions (i.e., provideAdapter, provideUtility, etc.) 
and "defineService" from the __init__.py imports
 * change all global services to classes with appropriate methods as per 
interfaces
 * update all tests 
 * remove all of the "provide*" functions from the interfaces
 * renamed IComponentArchitecture to IPlacefulComponentArchitecture (hereafter IPCA), after long discussion with SteveA 
 * list Resources as one of core CA services in IPlacefulComponentArchitecture
 * build actual IPCA interface, not just import of service interfaces (because we want IPCA to be placeful, but the service interfaces do not need to be)
 * place functions implementing ICA actually in __init__
 * explicitly setting up services in zcml
 * created Global service interfaces, and placed the "provides" and "set" and "define" functions there: however, to keep the main interfaces clean and clear, I placed these global interfaces in the same file as the global implementations, hoping to clarify that these are not reusable interfaces but descriptive, one-time interfaces
 * built PlacefulSetup in Zope.ComponentArchitecture.tests for more specific CleanUp (a subclass).  PlacefulSetup is in the tests folder of the local ServiceManager.  AddableSetup also is available, in the AddableService tests.

(elsewhere in Zope3)
 * built for_container in addables
 * built isAddable for containers (after discussion with Jim, we decided an addable "contains" attribute in the zcml might not be the way to go.  I chose the isAddable approach for a number of reasons)
 * addableservice does some more checks in getting the addable list, pertinent to the above and to whether it can find the appropriate factories
 * a few more tests: a start of one in the local event service, and some more here and there

I'm sorry to add to the confusion of the big security changes, but I needed to either trash these changes or commit them: I'm a bit out of time for the moment.  If all else fails, again, I did tag the previous version.



=== Added File Zope3/lib/python/Zope/ComponentArchitecture/tests/PlacelessSetup.py ===
##############################################################################
#
# Copyright (c) 2001, 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.
# 
##############################################################################
"""

Revision information:
$Id: PlacelessSetup.py,v 1.1.2.1 2002/04/29 23:20:10 poster Exp $
"""

# A mix-in class inheriting from CleanUp that also connects the CA services

from Zope.Testing.CleanUp import CleanUp
from Zope.ComponentArchitecture import getServiceManager

class PlacelessSetup(CleanUp):
    def setUp(self):
        CleanUp.setUp(self)
        sm=getServiceManager(None)
        defineService=sm.defineService
        provideService=sm.provideService
        # factory service
        from Zope.ComponentArchitecture.IFactoryService import IFactoryService
        defineService('Factories',IFactoryService)
        from Zope.ComponentArchitecture.GlobalFactoryService import\
             factoryService
        provideService('Factories', factoryService)
        # utility service
        from Zope.ComponentArchitecture.IUtilityService import IUtilityService
        defineService('Utilities',IUtilityService)
        from Zope.ComponentArchitecture.GlobalUtilityService import\
             utilityService
        provideService('Utilities', utilityService)
        # adapter service
        from Zope.ComponentArchitecture.IAdapterService import IAdapterService
        defineService('Adapters',IAdapterService)
        from Zope.ComponentArchitecture.GlobalAdapterService import\
             adapterService
        provideService('Adapters', adapterService)
        # resource service
        from Zope.ComponentArchitecture.IResourceService import IResourceService
        defineService('Resources',IResourceService)
        from Zope.ComponentArchitecture.GlobalResourceService import\
             resourceService
        provideService('Resources', resourceService)
        # skin service
        from Zope.ComponentArchitecture.ISkinService import ISkinService
        defineService('Skins',ISkinService)
        from Zope.ComponentArchitecture.GlobalSkinService import\
             skinService
        provideService('Skins', skinService)
        # view service
        from Zope.ComponentArchitecture.IViewService import IViewService
        defineService('Views',IViewService)
        from Zope.ComponentArchitecture.GlobalViewService import\
             viewService
        provideService('Views', viewService)
    def tearDown(self):
        CleanUp.tearDown(self)

=== Zope3/lib/python/Zope/ComponentArchitecture/tests/TestFactory.py 1.1.2.2 => 1.1.2.3 ===
 # 
 ##############################################################################
+"""
 
+$Id$
+"""
 from Zope.ComponentArchitecture.IFactory import IFactory
+from Interface import Interface
 
-class X: pass
+class IX(Interface):
+    """the dummy interface which class X supposedly implements,
+    according to the factory"""
 
-def f():
-    return X()
+class X:
+    __implements__=IX
+    def __init__(self, *args, **kwargs):
+        self.args=args
+        self.kwargs=kwargs
 
-f.__implements__ = IFactory
+
+class ClassFactoryWrapper:
+    __implements__ = IFactory
+    def __init__(self, klass):
+        self.__klass=klass
+    def __call__(self, *args, **kwargs):
+        return self.__klass(*args, **kwargs)
+    def getInterfaces(self):
+        return getattr(self.__klass,'__implements__', None)
+
+f=ClassFactoryWrapper(X)
\ No newline at end of file


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testAPI.py 1.1.2.14 => 1.1.2.15 ===
 ##############################################################################
 import unittest, sys, Interface
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
 
 class I1(Interface.Interface): pass
 class I2(Interface.Interface): pass
@@ -33,10 +32,12 @@
 
 ob = Ob()
 
-class Test(CleanUp, unittest.TestCase):
+from PlacelessSetup import PlacelessSetup
+
+class Test(PlacelessSetup, unittest.TestCase):
 
     def testAdapter(self):
-        from Zope.ComponentArchitecture import getAdapter, provideAdapter
+        from Zope.ComponentArchitecture import getAdapter, getService
         from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
 
         # if an object implements the interface you want to adapt to,
@@ -50,52 +51,51 @@
         # ...otherwise, you get the default
         self.assertEquals(getAdapter(ob, I2, Test), Test)
         
-        provideAdapter(I1, I2, Comp)
+        getService(None, 'Adapters').provideAdapter(I1, I2, Comp)
         c = getAdapter(ob, I2)
         self.assertEquals(c.__class__, Comp)
         self.assertEquals(c.getContext(), ob)
 
     def testMultipleAdapterFactories(self):
-        from Zope.ComponentArchitecture import getAdapter, provideAdapter
+        from Zope.ComponentArchitecture import getAdapter, getService
 
         # Basically, this represents a 2-stage adaptation. You can get
         # from I1 to I2 by way of adapter Comp adapting Comp2
-        provideAdapter(I1, I2, [Comp2, Comp])
+        getService(None, 'Adapters').provideAdapter(I1, I2, [Comp2, Comp])
         c = getAdapter(ob, I2)
         self.assertEquals(c.__class__, Comp)
         self.assertEquals(c.getContext().getContext(), ob)
 
     def testAdapterForInterfaceNone(self):
-        from Zope.ComponentArchitecture import getAdapter, provideAdapter
+        from Zope.ComponentArchitecture import getAdapter, getService
         
         # providing an adapter for None says that your adapter can
         # adapt anything to I2.
-        provideAdapter(None, I2, Comp)
+        getService(None, 'Adapters').provideAdapter(None, I2, Comp)
         c = getAdapter(ob, I2)
         self.assertEquals(c.__class__, Comp)
         self.assertEquals(c.getContext(), ob)
 
     def testUtility(self):
-        from Zope.ComponentArchitecture import getUtility, provideUtility
+        from Zope.ComponentArchitecture import getUtility, 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)
         
-        provideUtility(I2, comp)
+        getService(None, 'Utilities').provideUtility(I2, comp)
         self.assertEquals(id(getUtility(ob, I2)), id(comp))
 
     def testView(self):
-        from Zope.ComponentArchitecture import provideView
-        from Zope.ComponentArchitecture import getView
+        from Zope.ComponentArchitecture import getView, 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)
         
-        provideView(I1, 'foo', I2, Comp)
+        getService(None, 'Views').provideView(I1, 'foo', I2, Comp)
         c = getView(ob, 'foo', I2)
         self.assertEquals(c.__class__, Comp)
         self.assertEquals(c.getContext(), ob)
@@ -109,9 +109,9 @@
         self.assertEquals(getView( ob, 'foo2', I1, None), None)    
 
     def testDefaultViewName(self):
-        from Zope.ComponentArchitecture.ViewService import ViewService
+        from Zope.ComponentArchitecture import getService
         from Zope.Exceptions import NotFoundError
-        viewService = ViewService()
+        viewService = getService(None, 'Views')
         self.assertRaises(NotFoundError,
                           viewService.getDefaultViewName,
                           ob, I1)


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testDirectives.py 1.1.2.7 => 1.1.2.8 ===
 from Zope.ComponentArchitecture import getView, getResource, createObject
 from cStringIO import StringIO
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from PlacelessSetup import PlacelessSetup
 from Zope.ComponentArchitecture import getDefaultViewName
 
 template = """<zopeConfigure
@@ -31,7 +31,7 @@
 class Ob:
     __implements__ = IC
 
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacelessSetup, unittest.TestCase):
 
     # XXX: tests for other directives needed
 
@@ -128,7 +128,7 @@
         
         self.assertEqual(getResource(ob, 'test', IV, None).__class__, R1)
          
-    def testSKinResource(self):
+    def testSkinResource(self):
 
         ob = Ob()
         self.assertEqual(getResource(ob, 'test', IV, None), None)


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testProvideFactory.py 1.1.2.2 => 1.1.2.3 ===
 # 
 ##############################################################################
-"""Test the provideFactory function."""
+"""Test the provideFactory method.
 
-import unittest
+$Id$
+"""
 
-from Zope.ComponentArchitecture.IFactory import IFactory
-from Zope.ComponentArchitecture import provideFactory, createObject
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
 
-class MyThing:
-    pass
+from unittest import TestCase, TestSuite, main, makeSuite
+from PlacelessSetup import PlacelessSetup
 
-class MyFactory:
-    __implements__ = IFactory
 
-    def __call__(self):
-        return MyThing()
+class ProvideFactoryTestCase(PlacelessSetup, TestCase):
 
-
-class ProvideFactoryTestCase(CleanUp, unittest.TestCase):
     def test_provide_factory(self):
-        provideFactory("Some.Object", MyFactory())
+        from Zope.ComponentArchitecture import getService, createObject
+        from TestFactory import f, X, IX
+        factories=getService(None, 'Factories')
+        factories.provideFactory("Some.Object", f)
         thing = createObject(None,"Some.Object")
-        self.assert_(isinstance(thing, MyThing))
+        self.assert_(isinstance(thing, X))
 
 
 def test_suite():
-    return unittest.makeSuite(ProvideFactoryTestCase)
+    return TestSuite((
+        makeSuite(ProvideFactoryTestCase),
+        ))
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testResources.py 1.1.2.4 => 1.1.2.5 ===
 import unittest, sys
 
-from Zope.ComponentArchitecture import defineSkin, provideResource
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture import getService
+from PlacelessSetup import PlacelessSetup
 from Zope.ComponentArchitecture import getResource
 from Zope.ComponentArchitecture import getRequestResource
 from Zope.ComponentArchitecture.Exceptions import ComponentLookupError 
 from Interface import Interface
 from Request import Request
 
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacelessSetup, unittest.TestCase):
 
     def testSkin(self):
         class I2(Interface): pass
         class C1:  __implements__ = I2
         class C2(C1): pass
 
-        provideResource('test', I2, C1())
+        getService(None,'Resources').provideResource('test', I2, C1())
         self.assertEqual(getResource(None, 'test', I2).__class__, C1) 
-        defineSkin('foo', I2, ('foo', ''))
+        getService(None,'Skins').defineSkin('foo', I2, ('foo', ''))
         self.assertEqual(getResource(None, 'test', I2, skin='foo').__class__,
                          C1) 
-        provideResource('test', I2, C2(), layer='foo')
+        getService(None,'Resources').provideResource('test', I2, C2(),
+ layer='foo')
         self.assertEqual(getResource(None, 'test', I2, skin='foo').__class__,
                          C2) 
 
@@ -48,18 +49,19 @@
         class C2(C1): pass
         
 
-        provideResource('test', I2, C1())
+        getService(None,'Resources').provideResource('test', I2, C1())
         self.assertEqual(
             getRequestResource(None, 'test', Request(I2, '') ).__class__,
             C1) 
-        defineSkin('foo', I2, ('foo', ''))
+        getService(None,'Skins').defineSkin('foo', I2, ('foo', ''))
         self.assertEqual(
             getRequestResource(None, 'test', Request(I2, 'foo')).__class__,
             C1)
-        provideResource('test', I2, C2(), layer='foo')
+        getService(None,'Resources').provideResource('test', I2, C2(),
+ layer='foo')
         self.assertEqual(
             getRequestResource(None, 'test', Request(I2, 'foo')).__class__,
-            C2) 
+            C2)
 
         self.assertRaises(
             ComponentLookupError,  


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testService.py 1.1.2.7 => 1.1.2.8 ===
 """
 
-from Zope.ComponentArchitecture import defineService, provideService
-from Zope.ComponentArchitecture import getServiceDefinitions, getService
-from Zope.ComponentArchitecture.Service import UndefinedService, InvalidService
-from Zope.ComponentArchitecture.ServiceManagerContainer import ServiceManagerContainer
+from Zope.ComponentArchitecture import getServiceDefinitions, getService, \
+  getServiceManager
+from Zope.ComponentArchitecture.GlobalServiceManager import UndefinedService, \
+  InvalidService
+from Zope.ComponentArchitecture.ServiceManagerContainer import \
+  ServiceManagerContainer
 from Zope.Exceptions import DuplicationError
 from Interface import Interface
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.Testing.CleanUp import CleanUp
 
 import unittest, sys
 
@@ -41,23 +43,23 @@
 class Test(CleanUp, unittest.TestCase):
         
     def testNormal(self):
-        defineService('one', IOne)
+        getServiceManager(None).defineService('one', IOne)
         c = ServiceOne()
-        provideService('one', c)
+        getServiceManager(None).provideService('one', c)
         self.assertEqual(id(getService(None, 'one')), id(c))
 
     def testDup(self):
-        defineService('one', IOne)
+        getServiceManager(None).defineService('one', IOne)
         self.assertRaises(DuplicationError,
-                          defineService,
+                          getServiceManager(None).defineService,
                           'one', ITwo)
 
         c = ServiceOne()
-        provideService('one', c)
+        getServiceManager(None).provideService('one', c)
 
         c2 = ServiceOne()
         self.assertRaises(DuplicationError,
-                          provideService,
+                          getServiceManager(None).provideService,
                           'one', c2)
 
         self.assertEqual(id(getService(None, 'one')), id(c))
@@ -66,15 +68,15 @@
     def testUndefined(self):
         c = ServiceOne()
         self.assertRaises(UndefinedService,
-                          provideService,
+                          getServiceManager(None).provideService,
                           'one', c)
 
     def testInvalid(self):
-        defineService('one', IOne)
-        defineService('two', ITwo)
+        getServiceManager(None).defineService('one', IOne)
+        getServiceManager(None).defineService('two', ITwo)
         c = ServiceOne()
         self.assertRaises(InvalidService,
-                          provideService,
+                          getServiceManager(None).provideService,
                           'two', c)
 
     def testGetService(self):
@@ -82,21 +84,21 @@
         """Testing looking up a service from a service manager
         container that doesn't have a service manager."""
         
-        defineService('one', IOne)
+        getServiceManager(None).defineService('one', IOne)
         c = ServiceOne()
-        provideService('one', c)
+        getServiceManager(None).provideService('one', c)
         smc = ServiceManagerContainer()
         self.assertEqual(id(getService(smc, 'one')), id(c))
         
     def testGetServiceDefinitions(self):
         """test that the service definitions are the ones we added"""
-        defineService('one', IOne)
+        getServiceManager(None).defineService('one', IOne)
         c = ServiceOne()
-        provideService('one', c)
+        getServiceManager(None).provideService('one', c)
         
-        defineService('two', ITwo)
+        getServiceManager(None).defineService('two', ITwo)
         d = ServiceTwo()
-        provideService('two', d)
+        getServiceManager(None).provideService('two', d)
         defs = getServiceDefinitions(None)
         defs.sort()
         self.assertEqual(defs,


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testServiceManagerContainer.py 1.1.2.7 => 1.1.2.8 ===
 
 from unittest import TestCase, TestSuite, main, makeSuite
-from Zope.ComponentArchitecture.IServiceService import IServiceService
+from Zope.ComponentArchitecture.IServiceManager import IServiceManager
 from Zope.ComponentArchitecture.IServiceManagerContainer \
      import IServiceManagerContainer
 from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
@@ -27,18 +27,18 @@
 
 class ServiceManager:
 
-    __implements__ =  IServiceService
+    __implements__ =  IServiceManager
 
     ############################################################
     # Implementation methods for interface
-    # Zope.ComponentArchitecture.IServiceService.
+    # Zope.ComponentArchitecture.IServiceManager.
 
     def getService(self, object, name):
-        '''See interface IServiceService'''
+        '''See interface IServiceManager'''
         raise ComponentLookupError(name)
 
     def getServiceDefinitions(self):
-        '''See interface IServiceService'''
+        '''See interface IServiceManager'''
         return ()
 
     #


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testSkins.py 1.1.2.9 => 1.1.2.10 ===
 import unittest, sys
 
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-from Zope.ComponentArchitecture import defineSkin, provideView, getView
+from PlacelessSetup import PlacelessSetup
+from Zope.ComponentArchitecture import getView, getService
 from Zope.ComponentArchitecture import getRequestView
 from Zope.ComponentArchitecture.Exceptions import ComponentLookupError 
 from Interface import Interface
 from Request import Request
 
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacelessSetup, unittest.TestCase):
 
     def testSkin(self):
         class I1(Interface): pass
@@ -35,15 +35,15 @@
 
         class O: __implements__ = I1
 
-        provideView(I1, 'test', I2, C1)
+        getService(None, 'Views').provideView(I1, 'test', I2, C1)
         self.assertEqual(getView(O(), 'test', I2).__class__, C1) 
-        defineSkin('foo', I2, ('foo', ''))
+        getService(None, 'Skins').defineSkin('foo', I2, ('foo', ''))
         self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C1) 
-        provideView(None, 'test', I2, C2)
+        getService(None, 'Views').provideView(None, 'test', I2, C2)
         self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C1) 
-        provideView(None, 'test', I2, C2, layer='foo')
+        getService(None, 'Views').provideView(None, 'test', I2, C2, layer='foo')
         self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C2) 
-        provideView(I1, 'test', I2, C3, layer='foo')
+        getService(None, 'Views').provideView(I1, 'test', I2, C3, layer='foo')
         self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C3) 
 
 
@@ -63,22 +63,22 @@
         class O: __implements__ = I1
 
 
-        provideView(I1, 'test', I2, C1)
+        getService(None, 'Views').provideView(I1, 'test', I2, C1)
         self.assertEqual(getRequestView(O(), 'test', 
             Request(I2,'') ).__class__, C1) 
-        defineSkin('foo', I2, ('foo', ''))
+        getService(None, 'Skins').defineSkin('foo', I2, ('foo', ''))
 
         self.assertEqual(getRequestView(O(), 'test', 
             Request(I2, 'foo')).__class__, C1) 
-        provideView(None, 'test', I2, C2)
+        getService(None, 'Views').provideView(None, 'test', I2, C2)
 
         self.assertEqual(getRequestView(O(), 'test', 
             Request(I2, 'foo')).__class__, C1) 
-        provideView(None, 'test', I2, C2, layer='foo')
+        getService(None, 'Views').provideView(None, 'test', I2, C2, layer='foo')
 
         self.assertEqual(getRequestView(O(), 'test', 
             Request(I2, 'foo')).__class__, C2) 
-        provideView(I1, 'test', I2, C3, layer='foo')
+        getService(None, 'Views').provideView(I1, 'test', I2, C3, layer='foo')
 
         self.assertEqual(getRequestView(O(), 'test', 
             Request(I2, 'foo')).__class__, C3) 


=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testViewDefinitions.py 1.1.2.3 => 1.1.2.4 ===
 
 from unittest import TestCase, TestSuite, main, makeSuite
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from PlacelessSetup import PlacelessSetup
 from Zope.ComponentArchitecture.tests.TestViews \
      import IC, IV, V1
 
+from Zope.ComponentArchitecture import getService
+
 class IC1(IC): "Content interface 1"
 class IC2(IC): "Content interface 1"
 
 class ViewType(IV): "Custom view type"
 
-class BaseTestViewDefinitions:
+class BaseTestViewDefinitions(PlacelessSetup):
 
     def setUp(self):
+        PlacelessSetup.setUp(self)
         viewService = self._Test__new()
 
         for name in ('foo', 'bar', 'baz'):
@@ -62,7 +65,6 @@
                 C.__implements__ = ViewType
                 viewService.provideView(IC, name, IV, C,
                                         layer=layer)
-
         
         
     def testAll(self):
@@ -91,11 +93,10 @@
         from Interface.Verify import verifyObject
         verifyObject(IViewService, self._Test__new())
 
-class Test(BaseTestViewDefinitions, CleanUp, TestCase):
+class Test(BaseTestViewDefinitions, TestCase):
 
     def _Test__new(self):
-        from Zope.ComponentArchitecture.ViewService import viewService
-        return viewService
+        return getService(None, "Views")