views:

507

answers:

1

Hi all,

I want to make a captcha validation.

I get the key from the recaptcha website and already succeed to put the public key to load the webpage with the challenge.

<script type="text/javascript"
   src="http://api.recaptcha.net/challenge?k=&lt;your_public_key&gt;"&gt;
</script>

<noscript>
   <iframe src="http://api.recaptcha.net/noscript?k=&lt;your_public_key&gt;"
       height="300" width="500" frameborder="0"></iframe><br>
   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
   </textarea>
   <input type="hidden" name="recaptcha_response_field" 
       value="manual_challenge">
</noscript>

I download the reCaptcha Python plugin but I can not find any documentation on how to use it.

Does anyone have any idea on how to use this Python plugin? recaptcha-client-1.0.4.tar.gz (md5)

+2  A: 

It is quite straightforward. This is an example from a trivial trac plugin I'm using:

from recaptcha.client import captcha

if req.method == 'POST':
    response = captcha.submit(
        req.args['recaptcha_challenge_field'],
        req.args['recaptcha_response_field'],
        self.private_key,
        req.remote_addr,
        )
    if not response.is_valid:
        say_captcha_is_invalid()
    else:
        do_something_useful()
else:
    data['recaptcha_javascript'] = captcha.displayhtml(self.public_key)
    data['recaptcha_theme'] = self.theme
    return 'recaptchaticket.html', data, n
abbot
Hi abbot,I am new to Python, can you explain how to use the downloaded package in more details?
sfa
You should install it as a regular python package. I would recommend you reading some introductory course on python if you are new to all these things. You can try http://diveintopython.org/toc/index.html or http://docs.python.org/tutorial/index.html as a good starting point.
abbot