From 21a3e374541a5cef3499b421b26816ea45cddc89 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Tue, 24 Apr 2007 20:37:51 +0000
Subject: [PATCH] Use only content_type_registry to get portal_type by
 extension. Define more extensions.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14204 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../content_type_registry.xml                 |  4 +++
 ...onTool_getCandidateTypeListByExtension.xml | 28 +++----------------
 2 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/bt5/erp5_dms/PathTemplateItem/content_type_registry.xml b/bt5/erp5_dms/PathTemplateItem/content_type_registry.xml
index dcd91c5513..e221b57456 100644
--- a/bt5/erp5_dms/PathTemplateItem/content_type_registry.xml
+++ b/bt5/erp5_dms/PathTemplateItem/content_type_registry.xml
@@ -143,6 +143,7 @@
             <value>
               <list>
                 <string>sxd</string>
+                <string>odg</string>
               </list>
             </value>
         </item>
@@ -202,10 +203,12 @@
               <list>
                 <string>gif</string>
                 <string>jpg</string>
+                <string>jpeg</string>
                 <string>png</string>
                 <string>bmp</string>
                 <string>GIF</string>
                 <string>JPG</string>
+                <string>JPEG</string>
                 <string>PNG</string>
                 <string>BMP</string>
               </list>
@@ -293,6 +296,7 @@
                 <string>xls</string>
                 <string>ods</string>
                 <string>sdc</string>
+                <string>sxc</string>
               </list>
             </value>
         </item>
diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/ContributionTool_getCandidateTypeListByExtension.xml b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/ContributionTool_getCandidateTypeListByExtension.xml
index d2dcc13782..06548f2b52 100644
--- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/ContributionTool_getCandidateTypeListByExtension.xml
+++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/ContributionTool_getCandidateTypeListByExtension.xml
@@ -68,25 +68,8 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>typetoext = {\n
-  \'Text\':(\'doc\', \'sxw\', \'odt\', \'txt\', \'rtf\'),\n
-  \'Spreadsheet\':(\'xls\', \'sxc\', \'ods\'),\n
-  \'Presentation\':(\'ppt\', \'odp\'),\n
-  \'Drawing\':(\'odg\',),\n
-  \'Image\':(\'jpg\', \'jpeg\', \'gif\', \'bmp\', \'png\'),\n
-  \'PDF\':(\'pdf\',),\n
-}\n
-\n
-multitypes = {\n
-#     \'Text\':(\'Text\', \'Memo\')\n
-}\n
-context.log(ext)\n
-\n
-for ptype, ext_list in typetoext.items():\n
-  if ext in ext_list:\n
-    return multitypes.get(ptype, (ptype,))\n
-\n
-return ()\n
+            <value> <string>pt = context.content_type_registry.findTypeName(\'a.%s\' %ext, None, None)\n
+return pt\n
 </string> </value>
         </item>
         <item>
@@ -130,13 +113,10 @@ return ()\n
                         <value>
                           <tuple>
                             <string>ext</string>
-                            <string>typetoext</string>
-                            <string>multitypes</string>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>_getiter_</string>
-                            <string>ptype</string>
-                            <string>ext_list</string>
+                            <string>None</string>
+                            <string>pt</string>
                           </tuple>
                         </value>
                     </item>
-- 
2.30.9