Overview
WTForms-reCaptcha is a convenient field for WTForms that transparently handles reCaptcha display and validation via corresponding widget and validator classes.
reCaptcha
Installation
Get the distribution:
pip install wtforms-recaptcha
or if you want the latest:
pip install hg+http://bitbucket.org/excieve/wtforms-recaptcha#egg=wtforms-recaptcha
or get hg clone of the source code:
hg clone http://bitbucket.org/excieve/wtforms-recaptcha cd wtforms-recaptcha python setup.py install
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 wtfrecaptcha.fields import RecaptchaField
class CaptchaForm(Form):
captcha = RecaptchaField(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 RecaptchaField 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
See LICENSE for full licensing information.
Metadata
Release files for wtforms-recaptcha 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wtforms-recaptcha-0.3.2.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wtforms_recaptcha-0.3.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 13.9 kB
Release files / wtforms-recaptcha-0.3.2.tar.gz
| Download URL | wtforms-recaptcha-0.3.2.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b566bffea417b05beb3424ca777e8618beb25770ac237c37c0bf8dd1db0e8496
|
|
BLAKE2b-256 checksum How to use checksums |
20ae90bf651b4fb0fbbaa2851bfd2298d011f8b6110e4b6778b8d72ca308a1a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / wtforms_recaptcha-0.3.2-py2.py3-none-any.whl
| Download URL | wtforms_recaptcha-0.3.2-py2.py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a9ace04fd1a939325276794f1816a97ddd84ef1b11f3f328670f7341e4450cb3
|
|
BLAKE2b-256 checksum How to use checksums |
5cb042021ab061b768e3e5f430466219468c2afec99fe706e4340792d7a6fab4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |