[CMF-checkins] CVS: CMF - PortalFolder.py:1.15 TypesTool.py:1.14

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


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

Modified Files:
	PortalFolder.py TypesTool.py 
Log Message:
 - Make all content types findable by catalog (Tracker #286)


--- Updated File PortalFolder.py in package CMF --
--- PortalFolder.py	2001/05/26 16:35:30	1.14
+++ PortalFolder.py	2001/06/05 21:43:31	1.15
@@ -187,19 +187,6 @@
             return self.folder_contents(
                 self, REQUEST, portal_status_message="Folder added")
     
-    security.declarePublic('listContentTypes')
-    def listContentTypes(self, by_meta_type=0):
-        """
-           List all registered portal content types.
-        """
-        mtSet = {}
-        for info in getToolByName(self, 'portal_types').listTypeInfo():
-            if by_meta_type:
-                mtSet[info.Metatype()] = 1
-            else:
-                mtSet[info.Type()] = 1
-        return mtSet.keys()
-
     def _morphSpec(self, spec):
         '''
         spec is a sequence of meta_types, a string containing one meta type,
@@ -208,7 +195,8 @@
         contentish.
         '''
         new_spec = []
-        types = self.listContentTypes(1)
+        types_tool = getToolByName(self, 'portal_types')
+        types = types_tool.listContentTypes( container=self, by_metatype=1 )
         if spec is not None:
             if type(spec) == type(''):
                 spec = [spec]

--- Updated File TypesTool.py in package CMF --
--- TypesTool.py	2001/05/26 16:35:30	1.13
+++ TypesTool.py	2001/06/05 21:43:31	1.14
@@ -697,17 +697,22 @@
         return rval
 
     security.declareProtected(AccessContentsInformation, 'listContentTypes')
-    def listContentTypes( self ):
+    def listContentTypes( self, container=None, by_metatype=0 ):
         """
             Return list of content metatypes.
         """
-        result = []
-        for t in self.objectValues():
-            if not getattr(aq_base(t), '_isTypeInformation', 0):
-                continue
-            name = t.Type()
+        typenames = {}
+        for t in self.listTypeInfo( container ):
+
+            if by_metatype:
+                name = t.Metatype()
+            else:
+                name = t.Type()
+
             if name:
-                result.append(name)
+                typenames[ name ] = 1
+
+        result = typenames.keys()
         result.sort()
         return result