raise AkismetReject if Akismet rejects a comment as spam.

svn path=/plone.app.discussion/trunk/; revision=37276
This commit is contained in:
Timo Stollenwerk 2010-06-14 13:02:46 +00:00
parent ac84b232b8
commit e56bc65956

View File

@ -33,6 +33,11 @@ try:
except: except:
pass pass
try:
from collective.akismet.browser.validator import AkismetReject
except:
pass
from zope.interface import implements, Interface from zope.interface import implements, Interface
from zope.schema.interfaces import IField from zope.schema.interfaces import IField
from zope.component import adapts from zope.component import adapts
@ -56,6 +61,9 @@ class CaptchaValidator(validator.SimpleFieldValidator):
captcha = getMultiAdapter((aq_inner(self.context), self.request), captcha = getMultiAdapter((aq_inner(self.context), self.request),
name=settings.captcha) name=settings.captcha)
if not captcha.verify(input=value): if not captcha.verify(input=value):
if settings.captcha == 'akismet':
raise AkismetReject
else:
raise WrongCaptchaCode raise WrongCaptchaCode
else: else:
return True return True