<s> """<STR_LIT>""" <EOL> try : <EOL> import json <EOL> except ImportError : <EOL> import simplejson as json <EOL> from flask import current_app <EOL> from werkzeug import url_encode <EOL> try : <EOL> from flaskext . babel import gettext as _ <EOL> except ImportError : <EOL> _ = lambda ( s ) : s <EOL> RECAPTCHA_API_SERVER = '<STR_LIT>' <EOL> RECAPTCHA_SSL_API_SERVER = '<STR_LIT>' <EOL> RECAPTCHA_HTML = u'''<STR_LIT>''' <EOL> __all__ = [ "<STR_LIT>" ] <EOL> class RecaptchaWidget ( object ) : <EOL> def recaptcha_html ( self , server , query , options ) : <EOL> return RECAPTCHA_HTML % dict ( <EOL> script_url = '<STR_LIT>' % ( server , query ) , <EOL> frame_url = '<STR_LIT>' % ( server , query ) , <EOL> options = json . dumps ( options ) <EOL> ) <EOL> def __call__ ( self , field , error = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if current_app . config . get ( '<STR_LIT>' , False ) : <EOL> server = RECAPTCHA_SSL_API_SERVER <EOL> else : <EOL> server = RECAPTCHA_API_SERVER <EOL> try : <EOL> public_key = current_app . config [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> raise RuntimeError , "<STR_LIT>" <EOL> query_options = dict ( k = public_key ) <EOL> if field . recaptcha_error is not None : <EOL> query_options [ '<STR_LIT:error>' ] = unicode ( field . recaptcha_error ) <EOL> query = url_encode ( query_options ) <EOL> options = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> } <EOL> } <EOL> options . update ( current_app . config . get ( '<STR_LIT>' , { } ) ) <EOL> return self . recaptcha_html ( server , query , options ) </s>
