-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Using just the ActionsTool right now in order to get that all set up and then move to the other tools, I've gotten almost always there, but there is one set of tests that refuse to run right now, the ones in CMFCore.exportimport.tests.test_actions which derive from class _ActionSetup.

Here's the change I have made in the actions importer code so far:

- --------------------------------------------------
Index: actions.py
===================================================================
- --- actions.py  (revision 71182)
+++ actions.py  (working copy)
@@ -34,6 +34,8 @@
         import ActionProvider as z2IActionProvider
from Products.CMFCore.utils import getToolByName

+from zope.component import getUtility
+
_SPECIAL_PROVIDERS = ('portal_actions', 'portal_types', 'portal_workflow')


@@ -247,7 +249,7 @@
     """Import actions tool.
     """
     site = context.getSite()
- -    tool = getToolByName(site, 'portal_actions')
+    tool = getUtility(IActionsTool, context=site)

     importObjects(tool, '', context)

@@ -255,7 +257,7 @@
     """Export actions tool.
     """
     site = context.getSite()
- -    tool = getToolByName(site, 'portal_actions', None)
+    tool = getUtility(IActionsTool, context=site)
     if tool is None:
         logger = context.getLogger('actions')
         logger.info('Nothing to export.')
- ----------------------------------------------------------

As you can see, all I did was a straight replacement getToolByName -> getUtility. I have made the following change to _ActionSetup._initSite to try and make it work, similar changes have made other tests work:

- -----------------------------------------------------------
Index: test_actions.py
===================================================================
- --- test_actions.py (revision 71182)
+++ test_actions.py (working copy)
@@ -332,7 +332,9 @@

     def setUp(self):
         import Products.CMFCore
+        from Products.CMFCore.interfaces._tools import IActionsTool
         from Products.CMFCore.ActionsTool import ActionsTool
+        from zope.component import getGlobalSiteManager

         BodyAdapterTestCase.setUp(self)
         zcml.load_config('configure.zcml', Products.CMFCore)
@@ -342,17 +344,29 @@
         self._obj = site.portal_actions
         self._BODY = _ACTIONSTOOL_BODY

+        # utility registration
+        gsm = getGlobalSiteManager()
+        gsm.registerUtility(self._obj, IActionsTool)

+
class _ActionSetup(BaseRegistryTests):

     def _initSite(self, foo=2, bar=2):
- -        self.root.site = Folder(id='site')
+        from Products.CMFCore.ActionsTool import ActionsTool
+        from zope.component import getGlobalSiteManager
+
+        #self.root.site = Folder(id='site')
+        self.root.site = DummySite('site')
         site = self.root.site
         site.portal_membership = DummyMembershipTool()

         site.portal_actions = DummyActionsTool()
         site.portal_actions.addActionProvider('portal_actions')

+        # utility registration
+        gsm = getGlobalSiteManager()
+        gsm.registerUtility(site.portal_actions, IActionsTool)
+
         if foo > 0:
             site.portal_foo = DummyTool()
- ------------------------------------------------------------

I still get these tracebacks:

- -------------------------------------------------------------
Error in test test_remove_skip_purge (Products.CMFCore.exportimport.tests.test_actions.importActionProvidersT ests)
Traceback (most recent call last):
File "/usr/local/zope/opt/Zope-2.10-branch/lib/python/Testing/ ZopeTestCase/profiler.py", line 98, in __call__
    testMethod()
File "/usr/local/zope/210Instance/Products/CMFCore/exportimport/ tests/test_actions.py", line 609, in test_remove_skip_purge
    importActionProviders(context)
File "/usr/local/zope/210Instance/Products/CMFCore/exportimport/ actions.py", line 252, in importActionProviders
    tool = getUtility(IActionsTool, context=site)
File "/usr/local/zope/opt/Zope-2.10-branch/lib/python/zope/ component/_api.py", line 204, in getUtility
    utility = queryUtility(interface, name, context=context)
File "/usr/local/zope/opt/Zope-2.10-branch/lib/python/zope/ component/_api.py", line 210, in queryUtility return getSiteManager(context).queryUtility(interface, name, default) File "/usr/local/zope/opt/Zope-2.10-branch/lib/python/zope/ component/_api.py", line 48, in getSiteManager
    raise ComponentLookupError(*error.args)
ComponentLookupError: ('Could not adapt', <Products.CMFCore.tests.base.dummy.DummySite object at 0x2bc7ff0>, <InterfaceClass zope.component.interfaces.IComponentLookup>)
- ------------------------------------------------------------------

I have tried various different things in _initSite, including the whole site registration dance like this, which for right now happens in CMFDefault.setuphandlers.importVarious:

- ------------------------------------------------------------------
        enableSite(site, iface=IObjectManagerSite)
        components = PersistentComponents()
        components.__bases__ = (base,)
        site.setSiteManager(components)
        setSite(site)
- ------------------------------------------------------------------

I've spent several hours and can't make those tests work. Anyone have a hint for me?

jens


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFFYF3+RAx5nvEhZLIRAmptAKCOWsLKIqIT9JaLIR/ljedtTdnM8gCeK97m
vYkcTutjNY3RrhjrN1cBhcI=
=Isah
-----END PGP SIGNATURE-----
_______________________________________________
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to