[CMF-checkins] CVS: CMF/CMFCore - WorkflowTool.py:1.23

Tres Seaver tseaver@zope.com
Fri, 5 Jul 2002 09:43:42 -0400


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv12143/CMFCore

Modified Files:
	WorkflowTool.py 
Log Message:



  - Made the workflow tool compute chains using type names, as well
    as instances (Tracker #441).


=== CMF/CMFCore/WorkflowTool.py 1.22 => 1.23 ===
     security.declarePrivate('getDefaultChainFor')
     def getDefaultChainFor(self, ob):
-        if getattr(ob, '_isPortalContent', 0):
-            # Apply a default workflow to portal content.
+        types_tool = getToolByName( self, 'portal_types', None )
+        if ( types_tool is not None
+            and types_tool.getTypeInfo( ob ) is not None ):
             return self._default_chain
+
         return ()
 
     security.declarePrivate('getChainFor')
@@ -486,7 +488,9 @@
         Returns the chain that applies to the given object.
         '''
         cbt = self._chains_by_type
-        if hasattr(aq_base(ob), '_getPortalTypeName'):
+        if type(ob) == type(''):
+            pt = ob
+        elif hasattr(aq_base(ob), '_getPortalTypeName'):
             pt = ob._getPortalTypeName()
         else:
             pt = getattr( ob, 'meta_type', None )  # Use a common Zope idiom.