Some of the information here may be outdated, please check the book instead

If you need to use captcha we strongly suggest outsourcing to

It could not be easier. here is how to:

  • register at (they give you a privatekey and a publickey)
  • download this file and save it as models/
  • use the RECAPTCHA helper (defined in file above) as in the following...


public_key='xxx'  ### provided by
private_key='xxx' ### provided by
def index():
    if form.accepts(request.vars,session): response.flash='done!'
    elif form.errors.has_key('captcha'): response.flash='invalid capctha'
    else: response.flash='some other error in your form'
    return dict(form=form)

The RECAPTCHA helper works very much as the input helper but it always take (request,publickey,privatekey) and validates itself. If it does no pass validation an error message is stored in form.errors['captcha'] but not displayed. It is up to the developer to display the error as appropriate.

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.