Skip to content

arahayrabedian/wtforms-nocaptcha

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wtforms-nocaptcha

Overview

wtforms-nocaptcha is a convenient field for WTForms that transparently handles Google's No Captcha reCaptcha display and validation via corresponding widget and validator classes.

Usage

It is mostly the usual WTForms field that needs some extra data and parameters. Here's a simple example:

from wtforms.form import Form
from wtfnocaptcha.fields import NoCaptchaField


class CaptchaForm(Form):
    captcha = NoCaptchaField(public_key=RECAPTCHA_PUB_KEY, private_key=RECAPTCHA_PRIV_KEY, secure=True)


form = CaptchaForm(request.POST, captcha={'ip_address': request.META['REMOTE_ADDR']})
if form.validate():
    print "Captcha response is correct"
else:
    print form.errors['captcha']

Some description of field's parameters:

public_key:Public key generated by reCaptcha service
private_key:Private key generated by reCaptcha service
secure:True if it should be served via HTTPS, False otherwise. Default: False.
http_proxy:URL of HTTP proxy for API calls

When form with NocaptchaField is instantiated with bound fields, it must include captcha keyword parameter with dict that has 'ip_address' element.

Other details

Accessing field as a string will get the widget code with URLs that depend on secure parameter passed to the field.

HTTP errors and errors that are indepentent of user input are logged. Others are handled as validation errors.

License

WTForms-nocaptcha is released under BSD license.
Copyright (c) 2015 Evan Roman <[email protected]>
Forked from WTForms-reCaptcha by Artem Gluvchynsky available here: https://bitbucket.org/excieve/wtforms-recaptcha

See LICENSE for full licensing information.

About

No Captcha reCaptcha field for wtforms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%