<s> from django . conf import settings <EOL> from django import forms <EOL> from django . utils . encoding import smart_unicode <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from widgets import * <EOL> from recaptcha . client import captcha <EOL> class ReCaptchaField ( forms . CharField ) : <EOL> default_error_messages = { <EOL> '<STR_LIT>' : _ ( u'<STR_LIT>' ) <EOL> } <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . widget = ReCaptcha <EOL> self . required = True <EOL> super ( ReCaptchaField , self ) . __init__ ( * args , ** kwargs ) <EOL> def clean ( self , values ) : <EOL> super ( ReCaptchaField , self ) . clean ( values [ <NUM_LIT:1> ] ) <EOL> recaptcha_challenge_value = smart_unicode ( values [ <NUM_LIT:0> ] ) <EOL> recaptcha_response_value = smart_unicode ( values [ <NUM_LIT:1> ] ) <EOL> check_captcha = captcha . submit ( recaptcha_challenge_value , <EOL> recaptcha_response_value , settings . RECAPTCHA_PRIVATE_KEY , { } ) <EOL> if not check_captcha . is_valid : <EOL> raise forms . util . ValidationError ( self . error_messages [ '<STR_LIT>' ] ) <EOL> return values [ <NUM_LIT:0> ] </s>
