#NEWLINE# def submit( recaptcha_challenge_field , recaptcha_response_field , private_key , remoteip ) : #NEWLINE# #INDENT# "\n    Submits a reCAPTCHA request for verification. Returns RecaptchaResponse\n    for the request\n\n    recaptcha_challenge_field -- The value of recaptcha_challenge_field from the form\n    recaptcha_response_field -- The value of recaptcha_response_field from the form\n    private_key -- your reCAPTCHA private key\n    remoteip -- the user's ip address\n    " #NEWLINE# if ( not ( recaptcha_response_field and recaptcha_challenge_field and len ( recaptcha_response_field ) and len ( recaptcha_challenge_field ) ) ) : #NEWLINE# #INDENT# return RecaptchaResponse ( is_valid = False , error_code = 'incorrect-captcha-sol' ) #NEWLINE# #UNINDENT# headers = { #NEWLINE# #INDENT# 'Content-type' : 'application/x-www-form-urlencoded' , #NEWLINE# 'User-agent' : 'reCAPTCHA GAE Python' , #NEWLINE# #UNINDENT# } #NEWLINE# params = urllib . urlencode ( { #NEWLINE# #INDENT# 'privatekey' : private_key , #NEWLINE# 'remoteip' : remoteip , #NEWLINE# 'challenge' : recaptcha_challenge_field , #NEWLINE# 'response' : recaptcha_response_field , #NEWLINE# #UNINDENT# } ) #NEWLINE# httpresp = urlfetch . fetch ( url = ( 'http://%s/verify' % VERIFY_SERVER ) , payload = params , method = urlfetch . POST , headers = headers ) #NEWLINE# if ( httpresp . status_code == 200 ) : #NEWLINE# #INDENT# return_values = httpresp . content . splitlines ( ) #NEWLINE# return_code = return_values [ 0 ] #NEWLINE# if ( return_code == 'true' ) : #NEWLINE# #INDENT# return RecaptchaResponse ( is_valid = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return RecaptchaResponse ( is_valid = False , error_code = return_values [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return RecaptchaResponse ( is_valid = False , error_code = 'recaptcha-not-reachable' )