Commits

David Larlet committed 912f387

mimetypes.FOO performance problems, see http://bugs.python.org/issue5401 for details

  • Participants
  • Parent commits e20d6ac

Comments (0)

Files changed (2)

backends/MogileFSStorage.py

 import urlparse
 from StringIO import StringIO
-from mimetypes import guess_type
+import mimetypes
 
 from django.core.files.storage import Storage
 from django.core.exceptions import ImproperlyConfigured
     Either reproxy the path to perlbal, or serve the image outright
     """
     # not the best way to do this, since we create a client each time
-    mimetype = guess_type(key)[0] or "application/x-octet-stream"
+    mimetype = mimetypes.guess_type(key)[0] or "application/x-octet-stream"
     client = mogilefs.Client(settings.MOGILEFS_DOMAIN, settings.MOGILEFS_TRACKERS)
     if hasattr(settings, "SERVE_WITH_PERLBAL") and settings.SERVE_WITH_PERLBAL:
         # we're reproxying with perlbal

backends/S3Storage.py

 import os
-from mimetypes import guess_type
+import mimetypes
 
 try:
     from cStringIO import StringIO
         return AWSAuthConnection(*self._get_access_keys())
 
     def _put_file(self, name, content):
-        content_type = guess_type(name)[0] or "application/x-octet-stream"
+        content_type = mimetypes.guess_type(name)[0] or "application/x-octet-stream"
         self.headers.update({'x-amz-acl': self.acl, 'Content-Type': content_type})
         response = self.connection.put(self.bucket, name, content, self.headers)
         if response.http_response.status != 200: