[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/ - checkpoint with more tools and most of the strange error log messages gone

Jens Vagelpohl jens at dataflake.org
Thu Dec 28 16:05:41 EST 2006


Log message for revision 71661:
  - checkpoint with more tools and most of the strange error log messages gone
  

Changed:
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/testing.py
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/DynamicType.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/UndoTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/WorkflowTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_workflow.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/base/dummy.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MembershipTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/content_status_modify.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/undo.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/rejectItems.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/testing.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py
  U   CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py
  U   CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_exportimport.py

-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt	2006-12-28 21:05:37 UTC (rev 71661)
@@ -1,27 +1,33 @@
 Event Views
 -----------
 
-Set up Event and user.
-
-    >>> from Products.CMFCalendar.Event import Event 
-    >>> id = app.site._setObject('myEvent', Event('myEvent'))
-
-    >>> uf = app.site.acl_users
-    >>> uf._doAddUser('mgr', 'mgrpw', ['Manager'], [])
-
 Register the minimum number of utilities we need
 
     >>> from zope.component import getSiteManager
+    >>> from Products.CMFCore.interfaces import ICatalogTool
+    >>> from Products.CMFCore.interfaces import IConfigurableWorkflowTool
+    >>> from Products.CMFCore.interfaces import IMembershipTool
     >>> from Products.CMFCore.interfaces import IPropertiesTool
     >>> from Products.CMFCore.interfaces import ISkinsTool
     >>> from Products.CMFCore.interfaces import ITypesTool
     >>> from Products.CMFCore.interfaces import IURLTool
     >>> sm = getSiteManager()
+    >>> sm.registerUtility(app.site.portal_catalog, ICatalogTool)
+    >>> sm.registerUtility(app.site.portal_workflow, IConfigurableWorkflowTool)
+    >>> sm.registerUtility(app.site.portal_membership, IMembershipTool)
     >>> sm.registerUtility(app.site.portal_properties, IPropertiesTool)
     >>> sm.registerUtility(app.site.portal_skins, ISkinsTool)
     >>> sm.registerUtility(app.site.portal_types, ITypesTool)
     >>> sm.registerUtility(app.site.portal_url, IURLTool)
 
+Set up Event and user.
+
+    >>> uf = app.site.acl_users
+    >>> uf._doAddUser('mgr', 'mgrpw', ['Manager'], [])
+    >>> from AccessControl.SecurityManagement import newSecurityManager
+    >>> newSecurityManager(None, uf.getUser('mgr').__of__(uf))
+    >>> id = app.site.invokeFactory(type_name='Event', id='myEvent')
+
 Create the browser object we'll be using.
 
     >>> from Products.Five.testbrowser import Browser

Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/testing.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/testing.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/testing.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -53,3 +53,4 @@
         app._delObject('site')
         transaction.commit()
         ZopeTestCase.close(app)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -29,6 +29,7 @@
 
 from Products.CMFCore.interfaces import IActionsTool
 from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
 from Products.CMFCore.interfaces import IMembershipTool
 from Products.CMFCore.interfaces import IPropertiesTool
 from Products.CMFCore.interfaces import ISkinsTool
@@ -118,6 +119,11 @@
     def afterSetUp(self):
         newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
 
+        # Need to make sure we get a _clean_ datbase connection, otherwise
+        # tests are plagued by ZODB connection errors due to the way the
+        # FunctionalLayer sets up the portal.
+        self.app = ZopeTestCase.app()
+
         # sessioning setup
         sdm = self.app.session_data_manager
         self.app.REQUEST.set_lazy('SESSION', sdm.getSessionData)
@@ -126,6 +132,9 @@
         sm = getSiteManager()
         sm.registerUtility(self.app.site.portal_actions, IActionsTool)
         sm.registerUtility(self.app.site.portal_catalog, ICatalogTool)
+        sm.registerUtility( self.app.site.portal_workflow
+                          , IConfigurableWorkflowTool
+                          )
         sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
         sm.registerUtility(self.app.site.portal_properties, IPropertiesTool)
         sm.registerUtility(self.app.site.portal_skins, ISkinsTool)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -35,10 +35,10 @@
 from permissions import ModifyPortalContent
 from utils import _dtmldir
 from utils import _getAuthenticatedUser
-from utils import getToolByName
 
 from interfaces import ICallableOpaqueItem
 from interfaces import ICatalogTool
+from interfaces import IConfigurableWorkflowTool
 from interfaces.IOpaqueItems \
         import ICallableOpaqueItem as z2ICallableOpaqueItem
 
@@ -61,7 +61,7 @@
         return queryUtility(ICatalogTool)
 
     def _getWorkflowTool(self):
-        return getToolByName(self, 'portal_workflow', None)
+        return queryUtility(IConfigurableWorkflowTool)
 
     # Cataloging methods
     # ------------------

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -24,6 +24,8 @@
 from Globals import InitializeClass
 from Products.PluginIndexes.common import safe_callable
 from Products.ZCatalog.ZCatalog import ZCatalog
+
+from zope.component import queryUtility
 from zope.interface import implements
 from zope.interface import providedBy
 from zope.interface.declarations import getObjectSpecification
@@ -33,6 +35,7 @@
 from ActionProviderBase import ActionProviderBase
 from interfaces import ICatalogTool
 from interfaces import IIndexableObjectWrapper
+from interfaces import IConfigurableWorkflowTool
 from interfaces.portal_catalog \
         import IndexableObjectWrapper as z2IIndexableObjectWrapper
 from interfaces.portal_catalog import portal_catalog as z2ICatalogTool
@@ -43,7 +46,6 @@
 from utils import _dtmldir
 from utils import _getAuthenticatedUser
 from utils import _mergedLocalRoles
-from utils import getToolByName
 from utils import registerToolInterface
 from utils import UniqueObject
 
@@ -251,7 +253,7 @@
                        pghandler=None):
         # Wraps the object with workflow and accessibility
         # information just before cataloging.
-        wftool = getToolByName(self, 'portal_workflow', None)
+        wftool = queryUtility(IConfigurableWorkflowTool)
         if wftool is not None:
             vars = wftool.getCatalogVariablesFor(obj)
         else:

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/DynamicType.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/DynamicType.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/DynamicType.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -104,7 +104,7 @@
                     return icon
                 else:
                     # Relative to REQUEST['BASEPATH1']
-                    portal_url = getUtility(IURLTool)
+                    portal_url = getUtility(IURLTool).__of__(self)
                     res = portal_url(relative=1) + '/' + icon
                     while res[:1] == '/':
                         res = res[1:]

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/UndoTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/UndoTool.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/UndoTool.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -30,6 +30,7 @@
 from utils import _checkPermission
 from utils import _dtmldir
 from utils import _getAuthenticatedUser
+from utils import registerToolInterface
 from utils import UniqueObject
 
 
@@ -112,3 +113,5 @@
         object.manage_undo_transactions(transaction_info)
 
 InitializeClass(UndoTool)
+registerToolInterface('portal_undo', IUndoTool)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/WorkflowTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/WorkflowTool.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/WorkflowTool.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -37,6 +37,7 @@
 from permissions import ManagePortal
 from utils import _dtmldir
 from utils import Message as _
+from utils import registerToolInterface
 from utils import UniqueObject
 from WorkflowCore import ObjectDeleted
 from WorkflowCore import ObjectMoved
@@ -607,3 +608,5 @@
             ob.reindexObjectSecurity()
 
 InitializeClass(WorkflowTool)
+registerToolInterface('portal_workflow', IWorkflowTool)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_workflow.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_workflow.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_workflow.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -19,6 +19,8 @@
 import Testing
 
 from OFS.Folder import Folder
+
+from zope.component import getSiteManager
 from zope.interface import implements
 
 from Products.GenericSetup.testing import BodyAdapterTestCase
@@ -163,6 +165,10 @@
         self.root.site = Folder(id='site')
         site = self.root.site
         self.root.site.portal_workflow = DummyWorkflowTool()
+        sm = getSiteManager()
+        sm.registerUtility( self.root.site.portal_workflow
+                          , IConfigurableWorkflowTool
+                          )
         return site
 
 

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -16,6 +16,7 @@
 """
 
 from zope.component import adapts
+from zope.component import getSiteManager
 
 from Products.GenericSetup.interfaces import ISetupEnviron
 from Products.GenericSetup.utils import exportObjects
@@ -120,16 +121,16 @@
 def importWorkflowTool(context):
     """Import workflow tool and contained workflow definitions from XML files.
     """
-    site = context.getSite()
-    tool = getToolByName(site, 'portal_workflow')
+    sm = getSiteManager(context.getSite())
+    tool = sm.getUtility(IConfigurableWorkflowTool)
 
     importObjects(tool, '', context)
 
 def exportWorkflowTool(context):
     """Export workflow tool and contained workflow definitions as XML files.
     """
-    site = context.getSite()
-    tool = getToolByName(site, 'portal_workflow', None)
+    sm = getSiteManager(context.getSite())
+    tool = sm.queryUtility(IConfigurableWorkflowTool)
     if tool is None:
         logger = context.getLogger('workflow')
         logger.info('Nothing to export.')

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/base/dummy.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/base/dummy.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/base/dummy.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -403,7 +403,10 @@
     def notifyCreated(self, ob):
         self.test_notified = ob
 
+    def getCatalogVariablesFor(self, obj):
+        return {}
 
+
 class DummyCachingManager:
 
     def getHTTPCachingHeaders( self, content, view_name, keywords, time=None ):

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -29,6 +29,7 @@
 from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
 from Products.CMFCore.exceptions import NotFound
 from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
 from Products.CMFCore.interfaces import IContentish
 from Products.CMFCore.testing import EventZCMLLayer
 from Products.CMFCore.testing import TraversingZCMLLayer
@@ -129,6 +130,7 @@
         self.site._setObject('portal_catalog', DummyCatalog())
         sm.registerUtility(self.site.portal_catalog, ICatalogTool)
         self.site._setObject('portal_workflow', DummyWorkflowTool())
+        sm.registerUtility(self.site.portal_workflow, IConfigurableWorkflowTool)
         self.site.foo = TheClass('foo')
 
     def tearDown(self):

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MembershipTool.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MembershipTool.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -22,6 +22,7 @@
 from OFS.Folder import Folder
 
 from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.MemberDataTool import MemberDataTool
 from Products.CMFCore.PortalFolder import PortalFolder
@@ -139,6 +140,8 @@
         self.failIf( mdtool._members.has_key('user_foo') )
         self.failIf( hasattr(members.aq_self, 'user_foo') )
 
+        cleanUp()
+
     def test_getMemberById_nonesuch(self):
         INVALID_USER_ID = 'nonesuch'
 

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml	2006-12-28 21:05:37 UTC (rev 71661)
@@ -45,7 +45,13 @@
      interface="Products.CMFCore.interfaces.ITypesTool"
      object="/portal_types"/>
   <utility
+     interface="Products.CMFCore.interfaces.IUndoTool"
+     object="/portal_undo"/>
+  <utility
      interface="Products.CMFCore.interfaces.IURLTool"
      object="/portal_url"/>
+  <utility
+     interface="Products.CMFCore.interfaces.IConfigurableWorkflowTool"
+     object="/portal_workflow"/>
  </utilities>
 </componentregistry>

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/content_status_modify.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/content_status_modify.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/content_status_modify.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -1,11 +1,12 @@
 ##parameters=workflow_action, comment=''
 ##title=Modify the status of a content object
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFDefault.exceptions import WorkflowException
 from Products.CMFDefault.utils import Message as _
 
-wtool = getToolByName(script, 'portal_workflow')
+wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
+wtool = getToolByInterfaceName(script, wtool_iface)
 
 try:
     wtool.doActionFor(context, workflow_action, comment=comment)

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/undo.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/undo.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/undo.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -1,10 +1,12 @@
 ##parameters=transaction_info
 ##title=Undo transactions
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFDefault.utils import Message as _
 
-utool = getToolByName(script, 'portal_undo')
+utool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IUndoTool'
+                              )
 
 utool.undo(context, transaction_info)
 

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -2,7 +2,6 @@
 ##
 
 from Products.CMFCore.utils import getToolByInterfaceName
-from Products.CMFCore.utils import getToolByName
 from Products.CMFDefault.utils import decode
 from Products.CMFDefault.utils import getBrowserCharset
 
@@ -18,7 +17,8 @@
 utool = getToolByInterfaceName( script
                               , 'Products.CMFCore.interfaces.IURLTool'
                               )
-wtool = getToolByName(script, 'portal_workflow')
+wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
+wtool = getToolByInterfaceName(script, wtool_iface)
 portal_object = utool.getPortalObject()
 
 if not 'charset' in context.REQUEST.RESPONSE.getHeader('content-type'):

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/rejectItems.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/rejectItems.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/rejectItems.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -7,10 +7,15 @@
 ##parameters=items, comment=''
 ##title=
 ##
-wf_tool = context.portal_workflow # XXX getToolByName
+
+from Products.CMFCore.utils import getToolByInterfaceName
+
+wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
+wtool = getToolByInterfaceName(script, wtool_iface)
+
 for path in items:
     object = context.restrictedTraverse( path )
-    wf_tool.doActionFor( object, 'reject', comment=comment )
+    wtool.doActionFor( object, 'reject', comment=comment )
 
 context.REQUEST[ 'RESPONSE' ].redirect( '%s/review?%s'
                    % ( context.portal_url()

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/testing.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/testing.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/testing.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -50,3 +50,4 @@
         app._delObject('site')
         transaction.commit()
         ZopeTestCase.close(app)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -32,6 +32,12 @@
     layer = FunctionalLayer
 
     def afterSetUp(self):
+
+        # Need to make sure we get a _clean_ datbase connection, otherwise
+        # tests are plagued by ZODB connection errors due to the way the
+        # FunctionalLayer sets up the portal.
+        self.app = ZopeTestCase.app()
+
         self.portal = self.app.site
         sm = getSiteManager()
         sm.registerUtility(self.portal.portal_membership, IMembershipTool)

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -29,6 +29,7 @@
 from AccessControl.User import UnrestrictedUser
 
 from Products.CMFCore.interfaces import ICachingPolicyManager
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
 from Products.CMFCore.interfaces import IMembershipTool
 from Products.CMFCore.interfaces import ITypesTool
 from Products.CMFCore.testing import ConformsToContent
@@ -113,8 +114,12 @@
     layer = FunctionalLayer
 
     def afterSetUp(self):
+
         self.site = self.app.site
         sm = getSiteManager()
+        sm.registerUtility( self.app.site.portal_workflow
+                          , IConfigurableWorkflowTool
+                          )
         sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
         sm.registerUtility(self.app.site.portal_types, ITypesTool)
         newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -20,6 +20,10 @@
 
 from AccessControl.SecurityManagement import newSecurityManager
 
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
+from Products.CMFCore.interfaces import IMembershipTool
 from Products.CMFCore.PortalFolder import PortalFolder
 from Products.CMFCore.tests.base.dummy import DummyFolder
 from Products.CMFCore.tests.base.dummy import DummySite
@@ -89,6 +93,8 @@
         members = self.site._setObject( 'Members', PortalFolder('Members') )
         acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
         wtool = self.site._setObject( 'portal_workflow', DummyTool() )
+        sm = getSiteManager()
+        sm.registerUtility(self.site.portal_workflow, IConfigurableWorkflowTool)
 
         # permission
         mtool.createMemberArea('user_foo')

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -25,6 +25,7 @@
 from zope.component import getSiteManager
 
 from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
 from Products.CMFCore.interfaces import IMembershipTool
 from Products.CMFCore.interfaces import ITypesTool
 from Products.CMFCore.interfaces import IURLTool
@@ -38,8 +39,16 @@
     def afterSetUp(self):
         ZopeTestCase.FunctionalTestCase.afterSetUp(self)
 
+        # Need to make sure we get a _clean_ datbase connection, otherwise
+        # tests are plagued by ZODB connection errors due to the way the
+        # FunctionalLayer sets up the portal.
+        self.app = ZopeTestCase.app()
+
         sm = getSiteManager()
         sm.registerUtility(self.app.site.portal_catalog, ICatalogTool)
+        sm.registerUtility( self.app.site.portal_workflow
+                          , IConfigurableWorkflowTool
+                          )
         sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
         sm.registerUtility(self.app.site.portal_types, ITypesTool)
         sm.registerUtility(self.app.site.portal_url, IURLTool)

Modified: CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -23,6 +23,7 @@
 from DateTime.DateTime import DateTime
 
 from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
 from Products.CMFCore.interfaces import ITypesTool
 from Products.CMFCore.interfaces import IURLTool
 from Products.CMFCore.tests.base.dummy import DummyContent
@@ -168,6 +169,7 @@
         self.site = self.app.site
         sm = getSiteManager()
         sm.registerUtility(self.site.portal_catalog, ICatalogTool)
+        sm.registerUtility(self.site.portal_workflow, IConfigurableWorkflowTool)
         sm.registerUtility(self.site.portal_types, ITypesTool)
         sm.registerUtility(self.site.portal_url, IURLTool)
         self.site._setObject( 'topic', Topic('topic') )

Modified: CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_exportimport.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_exportimport.py	2006-12-28 19:13:13 UTC (rev 71660)
+++ CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_exportimport.py	2006-12-28 21:05:37 UTC (rev 71661)
@@ -18,6 +18,8 @@
 import unittest
 import Testing
 
+from zope.component import getSiteManager
+
 from Products.PythonScripts.PythonScript import PythonScript
 from Products.ExternalMethod.ExternalMethod import ExternalMethod
 
@@ -29,6 +31,7 @@
         import _WorkflowSetup as WorkflowSetupBase
 from Products.CMFCore.exportimport.tests.test_workflow \
         import DummyWorkflowTool
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
 from Products.CMFCore.testing import DummyWorkflow
 from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
 from Products.DCWorkflow.testing import ExportImportZCMLLayer
@@ -75,7 +78,9 @@
 
     def _initDCWorkflow( self, workflow_id ):
 
+        sm = getSiteManager()
         wf_tool = self.root.site.portal_workflow
+        sm.registerUtility(wf_tool, IConfigurableWorkflowTool)
         wf_tool._setObject( workflow_id, DCWorkflowDefinition( workflow_id ) )
 
         return wf_tool._getOb( workflow_id )



More information about the CMF-checkins mailing list