[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/app/copypastemove/ Remove the use of ztapi and zope.app.testing in zope.app.copypastemove.

Brian Sutherland jinty at web.de
Thu Apr 13 08:20:18 EDT 2006


Log message for revision 66929:
  Remove the use of ztapi and zope.app.testing in zope.app.copypastemove.

Changed:
  U   Zope3/branches/jim-adapter/src/zope/app/copypastemove/__init__.py
  U   Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_clipboard.py
  U   Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_rename.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/copypastemove/__init__.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/copypastemove/__init__.py	2006-04-13 11:05:41 UTC (rev 66928)
+++ Zope3/branches/jim-adapter/src/zope/app/copypastemove/__init__.py	2006-04-13 12:20:17 UTC (rev 66929)
@@ -447,9 +447,9 @@
     This adapter uses IObjectMover to move an item within the same container
     to a different name. We need to first setup an adapter for IObjectMover:
 
-      >>> from zope.app.testing import ztapi
       >>> from zope.app.container.interfaces import IContained
-      >>> ztapi.provideAdapter(IContained, IObjectMover, ObjectMover)
+      >>> gsm = zope.component.getGlobalSiteManager()
+      >>> gsm.registerAdapter(ObjectMover, (IContained, ), IObjectMover)
 
     To rename an item in a container, instantiate a ContainerItemRenamer
     with the container:
@@ -515,9 +515,9 @@
     To illustrate, we need to setup an IObjectMover, which is used in the
     renaming:
 
-      >>> from zope.app.testing import ztapi
       >>> from zope.app.container.interfaces import IContained
-      >>> ztapi.provideAdapter(IContained, IObjectMover, ObjectMover)
+      >>> gsm = zope.component.getGlobalSiteManager()
+      >>> gsm.registerAdapter(ObjectMover, (IContained, ), IObjectMover)
 
     To rename an item in an ordered container, we instantiate a
     OrderedContainerItemRenamer with the container:
@@ -682,13 +682,13 @@
     Finally, we need to register our handler for copy events:
 
       >>> from zope.lifecycleevent.interfaces import IObjectCopiedEvent
-      >>> from zope.app.testing import ztapi
-      >>> ztapi.subscribe([None, IObjectCopiedEvent], None, handler)
+      >>> gsm = zope.component.getGlobalSiteManager()
+      >>> gsm.registerHandler(handler, [None, IObjectCopiedEvent])
 
     and this function as a dispatcher:
 
-      >>> ztapi.subscribe([None, IObjectCopiedEvent], None,
-      ...                 dispatchToSublocations)
+      >>> gsm.registerHandler(dispatchToSublocations,
+      ...                     [None, IObjectCopiedEvent])
 
     When we notify that our root object has been copied:
 

Modified: Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_clipboard.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_clipboard.py	2006-04-13 11:05:41 UTC (rev 66928)
+++ Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_clipboard.py	2006-04-13 12:20:17 UTC (rev 66929)
@@ -22,7 +22,6 @@
 from zope.app.component.testing import PlacefulSetup
 from zope.app.principalannotation import PrincipalAnnotationUtility
 from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
-from zope.app.testing import ztapi
 
 from zope.app.copypastemove.interfaces import IPrincipalClipboard
 from zope.app.copypastemove import PrincipalClipboard
@@ -38,10 +37,11 @@
     def setUp(self):
         self.buildFolders()
 
-        ztapi.provideAdapter(IAnnotations, IPrincipalClipboard,
-                             PrincipalClipboard)
-        ztapi.provideUtility(IPrincipalAnnotationUtility,
-                             PrincipalAnnotationUtility())
+        gsm = zope.component.getGlobalSiteManager()
+        gsm.registerAdapter(PrincipalClipboard, (IAnnotations, ),
+                            IPrincipalClipboard)
+        gsm.registerUtility(PrincipalAnnotationUtility(),
+                            IPrincipalAnnotationUtility)
 
     def testAddItems(self):
         user = PrincipalStub('srichter')

Modified: Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_rename.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_rename.py	2006-04-13 11:05:41 UTC (rev 66928)
+++ Zope3/branches/jim-adapter/src/zope/app/copypastemove/tests/test_rename.py	2006-04-13 12:20:17 UTC (rev 66929)
@@ -18,12 +18,19 @@
 import unittest
 
 from zope.testing.doctestunit import DocTestSuite
-from zope.app.testing.placelesssetup import setUp, tearDown
+from zope.component.testing import setUp as setUpCA, tearDown as tearDownCA
+from zope.app.container.tests.placelesssetup import PlacelessSetup
 
+container_setup = PlacelessSetup()
+
+def setUp(test):
+    setUpCA()
+    container_setup.setUp()
+
 def test_suite():
     return unittest.TestSuite((
         DocTestSuite('zope.app.copypastemove',
-                     setUp=setUp, tearDown=tearDown),
+                     setUp=setUp, tearDown=tearDownCA),
         ))
 
 if __name__=='__main__':



More information about the Zope3-Checkins mailing list