#NEWLINE# def get_response( data ) : #NEWLINE# #INDENT# xml_head = '<?xml version="1.0" encoding="UTF-8" ?>' #NEWLINE# response_dict = { #NEWLINE# #INDENT# 'Response' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# message = data . get ( 'text' ) #NEWLINE# if ( data . get ( 'code' ) == SMS_API_ERROR ) : #NEWLINE# #INDENT# message = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( data . get ( 'code' ) != SMS_SUBMISSION_ACCEPTED ) : #NEWLINE# #INDENT# message = ( _ ( '[ERROR] %s' ) % message ) #NEWLINE# #UNINDENT# #UNINDENT# if message : #NEWLINE# #INDENT# messages = [ message ] #NEWLINE# sendouts = data . get ( 'sendouts' , [ ] ) #NEWLINE# if len ( sendouts ) : #NEWLINE# #INDENT# messages += sendouts #NEWLINE# #UNINDENT# response_dict . update ( { #NEWLINE# #INDENT# 'Response' : { #NEWLINE# #INDENT# 'Sms' : messages , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# response = ( xml_head + dict2xml ( response_dict ) ) #NEWLINE# return HttpResponse ( response , content_type = 'text/xml' )