captcha validation is working now.
svn path=/plone.formwidget.captcha/trunk/; revision=28638
This commit is contained in:
parent
4ea190686c
commit
465467d2dc
|
@ -1,9 +1,12 @@
|
|||
from Acquisition import aq_inner
|
||||
from zope import interface
|
||||
from z3c.form import form, field, button
|
||||
from zope import schema
|
||||
from zope.component import getMultiAdapter
|
||||
from z3c.form import form, field, button
|
||||
from plone.z3cform.layout import wrap_form
|
||||
from plone.formwidget.captcha.widget import CaptchaFieldWidget
|
||||
|
||||
|
||||
class ICaptchaForm(interface.Interface):
|
||||
captcha = schema.TextLine(title=u"Captcha",
|
||||
description=u"",
|
||||
|
@ -22,6 +25,13 @@ class BaseForm(form.Form):
|
|||
@button.buttonAndHandler(u'Save')
|
||||
def handleApply(self, action):
|
||||
data, errors = self.extractData()
|
||||
if data.has_key('captcha'):
|
||||
# Verify the user input against the captcha
|
||||
captcha = getMultiAdapter((aq_inner(self.context), self.request), name='captcha')
|
||||
if captcha.verify(data['captcha']):
|
||||
print 'Captcha validation passed.'
|
||||
else:
|
||||
print 'The code you entered was wrong, please enter the new one.'
|
||||
return
|
||||
|
||||
CaptchaForm = wrap_form(BaseForm)
|
Reference in New Issue