[CMF-checkins] CVS: CMF/CMFCore - DynamicType.py:1.13 PortalObject.py:1.6 TypesTool.py:1.44 WorkflowTool.py:1.33

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


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

Modified Files:
	DynamicType.py PortalObject.py TypesTool.py WorkflowTool.py 
Log Message:
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.12 => 1.13 ===
 
     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.5 => 1.6 ===
 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.43 => 1.44 ===
             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.32 => 1.33 ===
         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: