[CMF-checkins] CVS: CMF - ActionsTool.py:1.9.2.1 DiscussionTool.py:1.3.2.1 DynamicType.py:1.8.2.1 PortalFolder.py:1.15.2.1 TypesTool.py:1.14.2.1

tseaver@digicool.com tseaver@digicool.com
Tue, 5 Jun 2001 17:56:34 -0400 (EDT)


Update of /cvs-repository/CMF/CMFCore
In directory korak.digicool.com:/tmp/cvs-serv9653/CMFCore

Modified Files:
      Tag: alltypes_branch
	ActionsTool.py DiscussionTool.py DynamicType.py 
	PortalFolder.py TypesTool.py 
Log Message:


 - Make it possible to map "normal" Zope objects as content
   (Tracker #283):

   o Skin and tool code which currently queries the object
     for its Type in order to then ask the types tool for
     a TypeInfo object should instead just ask the types tool
     for type TypeInfo object directly.
   
   o Modify the TypesTool interface to signal that passing an
     object to 'getTypeInfo' is acceptable, with the semantic
     that the tool will attempt to find a TypeInfo object based
     on the tool's type or metatype.
 



--- Updated File ActionsTool.py in package CMF --
--- ActionsTool.py	2001/06/01 15:07:28	1.9
+++ ActionsTool.py	2001/06/05 21:56:03	1.9.2.1
@@ -194,25 +194,25 @@
         # Include actions from object.
         if object is not None:
             base = aq_base(object)
-            if hasattr(base, 'getTypeInfo'):
-                ti = object.getTypeInfo()
-                if ti is not None:
-                    defs = ti.getActions()
-                    if defs:
-                        c_url = info.content_url
-                        for d in defs:
-                            a = d['action']
-                            if a:
-                                url = c_url + '/' + a
-                            else:
-                                url = c_url
-                            actions.append({
-                                'id': d.get('id', None),
-                                'name': d['name'],
-                                'url': url,
-                                'permissions': d['permissions'],
-                                'category': d.get('category', 'object'),
-                                })
+            types_tool = getToolByName( self, 'portal_types' )
+            ti = types_tool.getTypeInfo( object )
+            if ti is not None:
+                defs = ti.getActions()
+                if defs:
+                    c_url = info.content_url
+                    for d in defs:
+                        a = d['action']
+                        if a:
+                            url = c_url + '/' + a
+                        else:
+                            url = c_url
+                        actions.append({
+                            'id': d.get('id', None),
+                            'name': d['name'],
+                            'url': url,
+                            'permissions': d['permissions'],
+                            'category': d.get('category', 'object'),
+                            })
             if hasattr(base, 'listActions'):
                 a = object.listActions(info)
                 if a:

--- Updated File DiscussionTool.py in package CMF --
--- DiscussionTool.py	2001/05/11 03:38:28	1.3
+++ DiscussionTool.py	2001/06/05 21:56:03	1.3.2.1
@@ -211,8 +211,7 @@
         '''
         if hasattr( content, 'allow_discussion' ):
             return content.allow_discussion
-        typeInfo = getToolByName(self, 'portal_types').getTypeInfo(
-            content.Type())
+        typeInfo = getToolByName(self, 'portal_types').getTypeInfo( content )
         if typeInfo:
             return typeInfo.allowDiscussion()
         return 0

--- Updated File DynamicType.py in package CMF --
--- DynamicType.py	2001/04/30 19:35:10	1.8
+++ DynamicType.py	2001/06/05 21:56:03	1.8.2.1
@@ -126,8 +126,7 @@
         tool = getToolByName(self, 'portal_types', None)
         if tool is None:
             return None
-        pt = self._getPortalTypeName()
-        return tool.getTypeInfo(pt)  # Can return None.
+        return tool.getTypeInfo(self)  # Can return None.
 
     # Support for dynamic icons
 

--- Updated File PortalFolder.py in package CMF --
--- PortalFolder.py	2001/06/05 21:43:31	1.15
+++ PortalFolder.py	2001/06/05 21:56:03	1.15.2.1
@@ -163,8 +163,7 @@
         """
         result = []
         portal_types = getToolByName(self, 'portal_types')
-        pt = self._getPortalTypeName()
-        myType = portal_types.getTypeInfo(pt)
+        myType = portal_types.getTypeInfo(self)
 
         if myType is not None:
             for contentType in portal_types.listTypeInfo():
@@ -293,7 +292,8 @@
         """
              Implement dublin core type
         """
-        ti = self.getTypeInfo()
+        portal_types = getToolByName(self, 'portal_types')
+        ti = portal_types.getTypeInfo(self)
         if ti is not None:
             return ti.Type()
         return self.meta_type

--- Updated File TypesTool.py in package CMF --
--- TypesTool.py	2001/06/05 21:43:31	1.14
+++ TypesTool.py	2001/06/05 21:56:03	1.14.2.1
@@ -666,8 +666,15 @@
         """
             Return an instance which implements the
             TypeInformation interface, corresponding to
-            the specified 'contentType'.
+            the specified 'contentType'.  If contentType is actually
+            an object, rather than a string, attempt to look up
+            the appropriate type info using its Type or meta_type.
         """
+        if type( contentType ) is not type( '' ):
+            try:
+                contentType = contentType._getPortalTypeName()
+            except:
+                contentType = contentType.meta_type
         ob = getattr( self, contentType, None )
         if getattr(aq_base(ob), '_isTypeInformation', 0):
             return ob