[CMF-checkins] CVS: CMF/CMFCore - DynamicType.py:1.11.4.2 PortalObject.py:1.3.38.3 TypesTool.py:1.37.4.5 WorkflowTool.py:1.24.4.9

Florent Guillaume fg@nuxeo.com
Sun, 4 Aug 2002 19:15:29 -0400


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

Modified Files:
      Tag: CMF-1_3-branch
	DynamicType.py PortalObject.py TypesTool.py WorkflowTool.py 
Log Message:
Merged changes from HEAD:

Made TypesTool and WorkflowTool rely exclusively on _getPortalTypeName()
to determine the portal type of an object. If the method doesn't exist
or returns None, then we're not looking at a portal object.

Now meta_type is not used as a fallback anymore. Portal objects should
be properly initialized if they want to participate in the portal types
or workflows.

Also ensured that the CMF root is not workflowable by setting its
portal_type to None.



=== CMF/CMFCore/DynamicType.py 1.11.4.1 => 1.11.4.2 ===
 
     security.declarePublic('getPortalTypeName')
     def getPortalTypeName(self):
-        '''
+        """
         Returns the portal type name that can be passed to portal_types.
-        '''
+        If the object is uninitialized, returns None.
+        """
         pt = self.portal_type
-        if pt is None:
-            # Provide a fallback.
-            pt = self.meta_type
         if callable( pt ):
             pt = pt()
         return pt


=== CMF/CMFCore/PortalObject.py 1.3.38.2 => 1.3.38.3 ===
 class PortalObjectBase(PortalFolder, SkinnableObjectManager):
 
     meta_type = 'Portal Site'
+    portal_type = None
     _isPortalRoot = 1
 
     # Ensure certain attributes come from the correct base class.


=== CMF/CMFCore/TypesTool.py 1.37.4.4 => 1.37.4.5 ===
             TypeInformation interface, corresponding to
             the specified 'contentType'.  If contentType is actually
             an object, rather than a string, attempt to look up
-            the appropriate type info using its portal_type or meta_type.
+            the appropriate type info using its portal_type.
         """
         if type( contentType ) is not type( '' ):
-            try:
+            if hasattr(aq_base(contentType), '_getPortalTypeName'):
                 contentType = contentType._getPortalTypeName()
-            except AttributeError:
-                # if we can't get or call it for any reason, fall back...
-                contentType = contentType.meta_type
+            else:
+                return None
         ob = getattr( self, contentType, None )
         if getattr(aq_base(ob), '_isTypeInformation', 0):
             return ob


=== CMF/CMFCore/WorkflowTool.py 1.24.4.8 => 1.24.4.9 ===
         elif hasattr(aq_base(ob), '_getPortalTypeName'):
             pt = ob._getPortalTypeName()
         else:
-            pt = getattr(ob, 'portal_type', None)
-            if pt is None:
-                return ()
+            pt = None
+
+        if pt is None:
+            return ()
 
         chain = None
         if cbt is not None: