#NEWLINE# def determine_format( request , serializer , default_format = 'application/json' ) : #NEWLINE# #INDENT# '\n    Tries to "smartly" determine which output format is desired.\n    \n    First attempts to find a ``format`` override from the request and supplies\n    that if found.\n    \n    If no request format was demanded, it falls back to ``mimeparse`` and the\n    ``Accepts`` header, allowing specification that way.\n    \n    If still no format is found, returns the ``default_format`` (which defaults\n    to ``application/json`` if not provided).\n    ' #NEWLINE# if request . GET . get ( 'format' ) : #NEWLINE# #INDENT# if ( request . GET [ 'format' ] in serializer . formats ) : #NEWLINE# #INDENT# return serializer . get_mime_for_format ( request . GET [ 'format' ] ) #NEWLINE# #UNINDENT# #UNINDENT# if request . GET . has_key ( 'callback' ) : #NEWLINE# #INDENT# return serializer . get_mime_for_format ( 'jsonp' ) #NEWLINE# #UNINDENT# if ( request . META . get ( 'HTTP_ACCEPT' , '*/*' ) != '*/*' ) : #NEWLINE# #INDENT# formats = ( list ( serializer . supported_formats ) or [ ] ) #NEWLINE# formats . reverse ( ) #NEWLINE# best_format = mimeparse . best_match ( formats , request . META [ 'HTTP_ACCEPT' ] ) #NEWLINE# if best_format : #NEWLINE# #INDENT# return best_format #NEWLINE# #UNINDENT# #UNINDENT# return default_format