Commit 407d2f8a authored by Romain Courteaud's avatar Romain Courteaud

Prevent failing if content_type_registry is not found

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26305 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 48101486
......@@ -57,9 +57,14 @@
Find by give filename extension which portal_type is the right one.\n
Use content_type_registry for that. \n
"""\n
from Products.CMFCore.utils import getToolByName\n
\n
pt = context.content_type_registry.findTypeName(\'a.%s\' %ext, None, None)\n
return (pt,)\n
registry = getToolByName(context, \'content_type_registry\', None)\n
if registry is None:\n
return (None, )\n
else:\n
pt = registry.findTypeName(\'a.%s\' %ext, None, None)\n
return (pt,)\n
</string> </value>
</item>
<item>
......@@ -97,9 +102,12 @@ return (pt,)\n
<value>
<tuple>
<string>ext</string>
<string>_getattr_</string>
<string>Products.CMFCore.utils</string>
<string>getToolByName</string>
<string>context</string>
<string>None</string>
<string>registry</string>
<string>_getattr_</string>
<string>pt</string>
</tuple>
</value>
......
40
\ No newline at end of file
43
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment