code: def _detect_content_type(self, filename):
          '''Determine the mimetype for a file.
  
          :param filename: Filename of file to detect.
          '''
          name, ext = os.path.splitext(filename)
          if not ext:
              raise MessageError('File requires an extension.')
          ext = ext.lower()
          if ext.lstrip('.') in self._banned_extensions:
              err = 'Extension "{0}" is not allowed.'
              raise MessageError(err.format(ext))
          if not mimetypes.inited:
              mimetypes.init()
          return mimetypes.types_map.get(ext, self._default_content_typef _detect_content_type(self, filename):
          '''Determine the mimetype for a file.
  
          :param filename: Filename of file to detect.
          '''
          name, ext = os.path.splitext(filename)
          if not ext:
              raise MessageError('File requires an extension.')
          ext = ext.lower()
          if ext.lstrip('.') in self._banned_extensions:
              err = 'Extension "{0}" is not allowed.'
              raise MessageError(err.format(ext))
          if not mimetypes.inited:
              mimetypes.init()
          return mimetypes.types_map.get(ext, self._default_content_type)
docs: Determine the mimetype for a file.
  
          :param filename: Filename of file to detect.