'Looks up the mime type for \'filename\'.
Uses the handlers in \'config\' to determine if the file should
be treated as a static file.
Args:
config: The app.yaml object to check the filename against.
filename: The name of the file.
Returns:
The mime type string.  For example, \'text/plain\' or \'image/gif\'.
None if this is not a static file.'

def __GetMimeTypeIfStaticFile(self, config, filename):

    if self.__FileNameImpliesStaticFile(filename):
        return self.__MimeType(filename)
    for handler in config.handlers:
        handler_type = handler.GetHandlerType()
        if (handler_type in ('static_dir', 'static_files')):
            if (handler_type == 'static_dir'):
                regex = os.path.join(re.escape(handler.GetHandler()), '.*')
            else:
                regex = handler.upload
            if re.match(regex, filename):
                return (handler.mime_type or self.__MimeType(filename))
    return None
