#NEWLINE# def _get_from_id_or_pk( self , id = None , pk = None , **kwargs ) : #NEWLINE# #INDENT# "\n        Returns an object given an id or pk, request directly with the\n        get_resource_url_detail method without filtering on ids\n        (as Django's ORM do).\n        " #NEWLINE# clone = self . _clone ( ) #NEWLINE# instance = clone . model ( ) #NEWLINE# if ( pk is None ) : #NEWLINE# #INDENT# instance . id = id #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# instance . pk = id #NEWLINE# #UNINDENT# extra_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# extra_args . update ( kwargs ) #NEWLINE# extra_args . update ( ROA_SSL_ARGS ) #NEWLINE# resource = Resource ( instance . get_resource_url_detail ( ) , filters = ROA_FILTERS , ** extra_args ) #NEWLINE# try : #NEWLINE# #INDENT# parameters = clone . query . parameters #NEWLINE# logger . debug ( ( 'Retrieving : "%s" through %s with parameters "%s" ' % ( clone . model . __name__ , resource . uri , force_unicode ( parameters ) ) ) ) #NEWLINE# response = resource . get ( headers = self . _get_http_headers ( ) , ** parameters ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# raise ROAException ( e ) #NEWLINE# #UNINDENT# response = force_unicode ( response . body_string ( ) ) . encode ( DEFAULT_CHARSET ) #NEWLINE# for ( local_name , remote_name ) in ROA_MODEL_NAME_MAPPING : #NEWLINE# #INDENT# response = response . replace ( remote_name , local_name ) #NEWLINE# #UNINDENT# data = self . model . get_parser ( ) . parse ( StringIO ( response ) ) #NEWLINE# serializer = self . model . get_serializer ( data = data ) #NEWLINE# if ( not serializer . is_valid ( ) ) : #NEWLINE# #INDENT# raise ROAException ( ( 'Invalid deserialization for %s model: %s' % ( self . model , serializer . errors ) ) ) #NEWLINE# #UNINDENT# return serializer . object