[Erp5-report] r35228 nicolas - /erp5/trunk/products/ERP5/Document/File.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed May 12 16:55:58 CEST 2010
Author: nicolas
Date: Wed May 12 16:55:54 2010
New Revision: 35228
URL: http://svn.erp5.org?rev=35228&view=rev
Log:
Use mimetypes_registry to guess content_type from filename
Modified:
erp5/trunk/products/ERP5/Document/File.py
Modified: erp5/trunk/products/ERP5/Document/File.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/File.py?rev=35228&r1=35227&r2=35228&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/File.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/File.py [utf8] Wed May 12 16:55:54 2010
@@ -26,8 +26,6 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
-
-import mimetypes
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Base import WorkflowMethod
@@ -36,13 +34,9 @@
from Products.ERP5.Document.Document import ConversionError
from Products.ERP5Type.Base import Base, removeIContentishInterface
from Products.CMFDefault.File import File as CMFFile
+from Products.CMFCore.utils import getToolByName
from OFS.Image import Pdata
import cStringIO
-
-# Mixin Import
-from Products.ERP5.mixin.cached_convertable import CachedConvertableMixin
-
-mimetypes.init()
def _unpackData(data):
"""
@@ -148,13 +142,16 @@
return self.hasData()
security.declareProtected(Permissions.ModifyPortalContent, 'guessMimeType')
- def guessMimeType(self, fname=''):
+ def guessMimeType(self, fname=None):
"""
get mime type from file name
"""
- if fname == '': fname = self.getSourceReference()
+ if not fname:
+ fname = self.getSourceReference()
if fname:
- content_type,enc = mimetypes.guess_type(fname)
+ portal = self.getPortalObject()
+ content_type = getToolByName(portal, 'mimetypes_registry').\
+ lookupExtension(fname)
if content_type is not None:
self.setContentType(content_type)
else:
More information about the Erp5-report
mailing list