- Fixed "global name 'WrongCaptchaCode' is not defined" if norobots captcha,

but no other validation package is installed.

svn path=/plone.app.discussion/trunk/; revision=40574
This commit is contained in:
Radim Novotny 2010-10-09 11:13:28 +00:00
parent f7ed357a83
commit 18e92f7a85
2 changed files with 13 additions and 2 deletions

View File

@ -4,6 +4,10 @@ Changelog
1.0b10 (unreleased)
-------------------
- Fixed "global name 'WrongCaptchaCode' is not defined" if norobots captcha,
but no other validation package is installed.
[naro]
- Check if there is a 'pending' review state in the current workflow for
comments instead of just checking for the 'comment_review_workflow'. This
allows integrators to use a custom review workflow. This fixes

View File

@ -21,6 +21,11 @@ from plone.app.discussion.interfaces import ICaptcha
from plone.app.discussion.interfaces import IDiscussionSettings
from plone.app.discussion.interfaces import IDiscussionLayer
try:
from collective.z3cform.norobots.validator import WrongNorobotsAnswer
except ImportError:
pass
try:
from plone.formwidget.captcha.validator import WrongCaptchaCode
except ImportError:
@ -31,7 +36,6 @@ try:
except ImportError:
pass
class CaptchaValidator(validator.SimpleFieldValidator):
implements(IValidator)
adapts(Interface, IDiscussionLayer, Interface, IField, Interface)
@ -48,7 +52,10 @@ class CaptchaValidator(validator.SimpleFieldValidator):
captcha = getMultiAdapter((aq_inner(self.context), self.request),
name=settings.captcha)
if not captcha.verify(input=value):
raise WrongCaptchaCode
if settings.captcha == 'norobots':
raise WrongNorobotsAnswer
else:
raise WrongCaptchaCode
else:
return True