Skip to content
Browse files

Avoid site error when we display a file whose mimetype is unknown.

closes #12061

svn path=/Products.Archetypes/trunk/; revision=13741
  • Loading branch information...
1 parent 0e60f38 commit ae2a450cb403594de1815d5a1f78144ea427e3f4 @tdesvenain tdesvenain committed Jul 27, 2011
View
4 CHANGES.txt
@@ -4,6 +4,10 @@ Changelog
1.7.7 - Unreleased
------------------
+- Avoid site error when we display a file whose mimetype is unknown.
+ Refs http://dev.plone.org/plone/ticket/12061.
+ [thomasdesvenain]
+
- Fixed initial content length used by textCounter. Length should be the length
of a unicode string, not the utf-8 string.
[vincentfretin]
View
9 Products/Archetypes/skins/archetypes/getBestIcon.py
@@ -7,16 +7,23 @@
##bind subpath=traverse_subpath
from Products.CMFCore.utils import getToolByName
from zExceptions import NotFound
+from Products.MimetypesRegistry.common import MimeTypeException
mtr = getToolByName(context, 'mimetypes_registry', None)
if mtr is None:
return context.getIcon()
-lookup = mtr.lookup(context.getContentType())
+
+try:
+ lookup = mtr.lookup(context.getContentType())
+except MimeTypeException:
+ return None
+
if lookup:
mti = lookup[0]
try:
context.restrictedTraverse(mti.icon_path)
return mti.icon_path
except (NotFound, KeyError, AttributeError): # Looking for 'NotFound' or KeyError
pass
+
return context.getIcon()
View
8 Products/Archetypes/skins/archetypes/lookupMime.py
@@ -7,8 +7,14 @@
##bind subpath=traverse_subpath
##parameters=name
+from Products.MimetypesRegistry.common import MimeTypeException
+
mimetool = context.mimetypes_registry
-mimetypes = mimetool.lookup(name)
+try:
+ mimetypes = mimetool.lookup(name)
+except MimeTypeException:
+ mimetypes = ()
+
if len(mimetypes):
return mimetypes[0].name()
else:

0 comments on commit ae2a450

Please sign in to comment.
Something went wrong with that request. Please try again.