From 1ca74ab079290e94f772ef11d2b874ed40900c25 Mon Sep 17 00:00:00 2001
From: Leonardo Rochael Almeida <leonardo@nexedi.com>
Date: Mon, 23 Nov 2009 17:18:38 +0000
Subject: [PATCH] make local copy of method that was removed on CMF 2. We will
 remove it as well eventually

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30824 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Tool/TypesTool.py | 37 ++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/product/ERP5Type/Tool/TypesTool.py b/product/ERP5Type/Tool/TypesTool.py
index 1d656edec3..c0b6b3cf5e 100644
--- a/product/ERP5Type/Tool/TypesTool.py
+++ b/product/ERP5Type/Tool/TypesTool.py
@@ -59,10 +59,47 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool):
         return None
     return self._getOb(portal_type, None)
 
+  security.declareProtected(Permissions.AddPortalContent, 'listDefaultTypeInformation')
+  def listDefaultTypeInformation(self):
+      # FIXME: This method is only used by manage_addTypeInformation below, and
+      # should be removed when that method starts raising NotImplementedError.
+      #
+      # Scans for factory_type_information attributes
+      # of all products and factory dispatchers within products.
+      import Products
+      res = []
+      products = self.aq_acquire('_getProducts')()
+      for product in products.objectValues():
+          product_id = product.getId()
+
+          if hasattr(aq_base(product), 'factory_type_information'):
+              ftis = product.factory_type_information
+          else:
+              package = getattr(Products, product_id, None)
+              dispatcher = getattr(package, '__FactoryDispatcher__', None)
+              ftis = getattr(dispatcher, 'factory_type_information', None)
+
+          if ftis is not None:
+              if callable(ftis):
+                  ftis = ftis()
+
+              for fti in ftis:
+                  mt = fti.get('meta_type', None)
+                  id = fti.get('id', '')
+
+                  if mt:
+                      p_id = '%s: %s (%s)' % (product_id, id, mt)
+                      res.append( (p_id, fti) )
+
+      return res
+
+
   security.declareProtected(Permissions.AddPortalContent,
                             'manage_addTypeInformation')
   def manage_addTypeInformation(self, add_meta_type, id=None,
                                 typeinfo_name=None, RESPONSE=None):
+    # FIXME: This method is deprecated and should be reimplemented as a blocker
+    # i.e. a method that always raises a NotImplementedError
     """
     Create a TypeInformation in self.
 
-- 
2.30.9