r13741 - in Products.Archetypes/trunk: . Products/Archetypes/skins/archetypes
"Thomas Desvenain" <[email protected]> Wed, 27 Jul 2011 11:37:12 +0000
| Newsgroups | gmane.comp.web.zope.plone.archetypes.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: thomasdesvenain
Date: Wed Jul 27 11:37:11 2011
New Revision: 13741
Modified:
Products.Archetypes/trunk/CHANGES.txt
Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/getBestIcon.py
Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/lookupMime.py
Log:
Avoid site error when we display a file whose mimetype is unknown.
closes #12061
Modified: Products.Archetypes/trunk/CHANGES.txt
==============================================================================
--- Products.Archetypes/trunk/CHANGES.txt (original)
+++ Products.Archetypes/trunk/CHANGES.txt Wed Jul 27 11:37:11 2011
@@ -4,6 +4,10 @@
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]
Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/getBestIcon.py
==============================================================================
--- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/getBestIcon.py (original)
+++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/getBestIcon.py Wed Jul 27 11:37:11 2011
@@ -7,11 +7,17 @@
##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:
@@ -19,4 +25,5 @@
return mti.icon_path
except (NotFound, KeyError, AttributeError): # Looking for 'NotFound' or KeyError
pass
+
return context.getIcon()
Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/lookupMime.py
==============================================================================
--- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/lookupMime.py (original)
+++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/lookupMime.py Wed Jul 27 11:37:11 2011
@@ -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:
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey