code: def valid_mimetype(type_, allow_none=True):
      
      if isinstance(type_, unicode_type):
          match = __IDX_PATTERN.match(type_)
          if match:
              return match.group(1) in __IDX_MAPPING
          else:
              return __is_ascii(type_, 1, __MAX_LEN)
      else:
          return type_ is None and allow_none
docs: Checks for validity of given type, optionally allowing for a None value. Note: Unknown idx/NUMBER notation, where
         NUMBER is not a known shorthand mapping, will be rejected, i.e. type_ is valid if it
         1)  is an ASCII-only string between 1 & 64 characters long
         2a) does not begin with "idx/" OR
         2b) begins with "idx/" and is followed by a known shorthand index (integer)